Bonjour,
J'ai une macro qui marche bien mais que je souhaiterais simplifier :
En effet, la première série transforme en majuscule chaque Nom dans plusieurs colonnes réparties à plusieurs endroits. Je souhaiterais que cette transformation soit liée au nom des colonnes et non à leur emplacement dans le tableau :
Idem pour les lignes qui transforment en majuscules la première lettre du mot :
Idem pour les lignes qui vérifient que les valeurs rentrées sont bien des dates et qui indiquent les erreurs en rouge avec un message d'alerte. Stoppent la procédure s'il y a des erreurs :
Colonnes :
D : Date lettre candidat
E : Date lettre attente
F : Date reponse
R : Date annonce
U : Date entretien n°1
V : Date entretien n°2
W : Date entretien n°3
Y : Date denvoi
Z : Date de retour
Merci pour votre aide
J'ai une macro qui marche bien mais que je souhaiterais simplifier :
En effet, la première série transforme en majuscule chaque Nom dans plusieurs colonnes réparties à plusieurs endroits. Je souhaiterais que cette transformation soit liée au nom des colonnes et non à leur emplacement dans le tableau :
'Transforme en majuscule chaque Nom dans la colonne NOM'
Range("B1", Range("B1").EntireColumn.Find(What:="*", SearchDirection:=xlPrevious)).Select
For Each cell In Selection
cell.Value = UCase(cell.Value)
Next cell
'Transforme en majuscule chaque Mot dans la colonne BUREAU DISTRIBUTEUR'
Range("K1", Range("K1").EntireColumn.Find(What:="*", SearchDirection:=xlPrevious)).Select
For Each cell In Selection
cell.Value = UCase(cell.Value)
Next cell
'Transforme en majuscule chaque Mot dans la colonne CANDIDATURE SPONTANNEE'
Range("L1", Range("L1").EntireColumn.Find(What:="*", SearchDirection:=xlPrevious)).Select
For Each cell In Selection
cell.Value = UCase(cell.Value)
Next cell
'Transforme en majuscule chaque Mot dans la colonne REPONSE A ANNONCE'
Range("Q1", Range("Q1").EntireColumn.Find(What:="*", SearchDirection:=xlPrevious)).Select
For Each cell In Selection
cell.Value = UCase(cell.Value)
Next cell
'Transforme en majuscule chaque Mot dans la colonne SERVICE'
Range("X1", Range("X1").EntireColumn.Find(What:="*", SearchDirection:=xlPrevious)).Select
For Each cell In Selection
cell.Value = UCase(cell.Value)
Next cell
'Transforme en majuscule chaque Mot dans la colonne REPONSE A CANDIDATURE'
Range("G1", Range("G1").EntireColumn.Find(What:="*", SearchDirection:=xlPrevious)).Select
For Each cell In Selection
cell.Value = UCase(cell.Value)
Next cell
'Transforme en majuscule chaque Mot dans la colonne REPONSE DU SERVICE'
Range("AA1", Range("AA1").EntireColumn.Find(What:="*", SearchDirection:=xlPrevious)).Select
For Each cell In Selection
cell.Value = UCase(cell.Value)
Next cell
Idem pour les lignes qui transforment en majuscules la première lettre du mot :
'Transforme en majuscule la première lettre de chaque Prénom dans la colonne PRENOM'
Range("C1", Range("C1").EntireColumn.Find(What:="*", SearchDirection:=xlPrevious)).Select
For Each cell In Selection
cell.Formula = StrConv(cell.Formula, vbProperCase)
Next cell
'Transforme en majuscule la première lettre de chaque Mot dans les colonnes ADRESSES N°1 et N°2'
Range("H1:I1", Range("H1:I1").EntireColumn.Find(What:="*", SearchDirection:=xlPrevious)).Select
For Each cell In Selection
cell.Formula = StrConv(cell.Formula, vbProperCase)
Next cell
'Transforme en majuscule la première lettre de chaque Mot dans les colonnes POSTE DEMANDE N°1 à TOUT POSTE'
Range("M1😛1", Range("M1😛1").EntireColumn.Find(What:="*", SearchDirection:=xlPrevious)).Select
For Each cell In Selection
cell.Formula = StrConv(cell.Formula, vbProperCase)
Next cell
'Transforme en majuscule la première lettre de chaque Mot dans les colonnes POSTE DEMANDE N°1 à TOUT POSTE'
Range("S1:T1", Range("S1:T1").EntireColumn.Find(What:="*", SearchDirection:=xlPrevious)).Select
For Each cell In Selection
cell.Formula = StrConv(cell.Formula, vbProperCase)
Next cell
Idem pour les lignes qui vérifient que les valeurs rentrées sont bien des dates et qui indiquent les erreurs en rouge avec un message d'alerte. Stoppent la procédure s'il y a des erreurs :
Colonnes :
D : Date lettre candidat
E : Date lettre attente
F : Date reponse
R : Date annonce
U : Date entretien n°1
V : Date entretien n°2
W : Date entretien n°3
Y : Date denvoi
Z : Date de retour
'vérifie que les valeurs rentrées sont bien des dates et indique les erreurs en rouge avec un message d'alerte. Stoppe la procédure s'il y a des erreurs
Range("D2:F2", Range("D2:F2").EntireColumn.Find(What:="*", SearchDirection:=xlPrevious)).SpecialCells(xlCellTypeConstants).Select
For Each cell In Selection
If Not IsDate(cell) Or cell.NumberFormatLocal <> "jj/mm/aaaa" Or Right(cell, 4) < "2000" Then
cell.Select
cell.Font.ColorIndex = 3
cell.Interior.ColorIndex = 1
message = InputBox("Entrez un format de date (jj/mm/aaaa) en utilisant les symboles suivants :" & vbLf & " j pour jour" & vbLf & " m pour mois" & vbLf & " a pour année" & vbLf & "Exemple : " & Date)
If message = "" Then Exit Sub
cell.Value = message
cell.Font.ColorIndex = 1
cell.Interior.ColorIndex = 0
Do While Not IsDate(cell) Or cell.NumberFormatLocal <> "jj/mm/aaaa" Or Right(cell, 4) < "2000"
cell.Font.ColorIndex = 3
cell.Interior.ColorIndex = 1
message = InputBox("veuillez recommencer")
If message = "" Then Exit Sub
If Not IsDate(cell) Or cell.NumberFormatLocal <> "jj/mm/aaaa" Or Right(cell, 4) < "2000" Then
cell.Value = message
cell.Font.ColorIndex = 1
cell.Interior.ColorIndex = 0
Exit Do
End If
Loop
End If
Next
Range("R2:R2", Range("R2:R2").EntireColumn.Find(What:="*", SearchDirection:=xlPrevious)).SpecialCells(xlCellTypeConstants).Select
For Each cell In Selection
If Not IsDate(cell) Or cell.NumberFormatLocal <> "jj/mm/aaaa" Or Right(cell, 4) < "2000" Then
cell.Select
cell.Font.ColorIndex = 3
cell.Interior.ColorIndex = 1
message = InputBox("Entrez un format de date (jj/mm/aaaa) en utilisant les symboles suivants :" & vbLf & " j pour jour" & vbLf & " m pour mois" & vbLf & " a pour année" & vbLf & "Exemple : " & Date)
If message = "" Then Exit Sub
cell.Value = message
cell.Font.ColorIndex = 1
cell.Interior.ColorIndex = 0
Do While Not IsDate(cell) Or cell.NumberFormatLocal <> "jj/mm/aaaa" Or Right(cell, 4) < "2000"
cell.Font.ColorIndex = 3
cell.Interior.ColorIndex = 1
message = InputBox("veuillez recommencer")
If message = "" Then Exit Sub
If Not IsDate(cell) Or cell.NumberFormatLocal <> "jj/mm/aaaa" Or Right(cell, 4) < "2000" Then
cell.Value = message
cell.Font.ColorIndex = 1
cell.Interior.ColorIndex = 0
Exit Do
End If
Loop
End If
Next
Range("U2:W2", Range("U2:W2").EntireColumn.Find(What:="*", SearchDirection:=xlPrevious)).SpecialCells(xlCellTypeConstants).Select
For Each cell In Selection
If Not IsDate(cell) Or cell.NumberFormatLocal <> "jj/mm/aaaa" Or Right(cell, 4) < "2000" Then
cell.Select
cell.Font.ColorIndex = 3
cell.Interior.ColorIndex = 1
message = InputBox("Entrez un format de date (jj/mm/aaaa) en utilisant les symboles suivants :" & vbLf & " j pour jour" & vbLf & " m pour mois" & vbLf & " a pour année" & vbLf & "Exemple : " & Date)
If message = "" Then Exit Sub
cell.Value = message
cell.Font.ColorIndex = 1
cell.Interior.ColorIndex = 0
Do While Not IsDate(cell) Or cell.NumberFormatLocal <> "jj/mm/aaaa" Or Right(cell, 4) < "2000"
cell.Font.ColorIndex = 3
cell.Interior.ColorIndex = 1
message = InputBox("veuillez recommencer")
If message = "" Then Exit Sub
If Not IsDate(cell) Or cell.NumberFormatLocal <> "jj/mm/aaaa" Or Right(cell, 4) < "2000" Then
cell.Value = message
cell.Font.ColorIndex = 1
cell.Interior.ColorIndex = 0
Exit Do
End If
Loop
End If
Next
Range("Y2:Z2", Range("Y2:Z2").EntireColumn.Find(What:="*", SearchDirection:=xlPrevious)).SpecialCells(xlCellTypeConstants).Select
For Each cell In Selection
If Not IsDate(cell) Or cell.NumberFormatLocal <> "jj/mm/aaaa" Or Right(cell, 4) < "2000" Then
cell.Select
cell.Font.ColorIndex = 3
cell.Interior.ColorIndex = 1
message = InputBox("Entrez un format de date (jj/mm/aaaa) en utilisant les symboles suivants :" & vbLf & " j pour jour" & vbLf & " m pour mois" & vbLf & " a pour année" & vbLf & "Exemple : " & Date)
If message = "" Then Exit Sub
cell.Value = message
cell.Font.ColorIndex = 1
cell.Interior.ColorIndex = 0
Do While Not IsDate(cell) Or cell.NumberFormatLocal <> "jj/mm/aaaa" Or Right(cell, 4) < "2000"
cell.Font.ColorIndex = 3
cell.Interior.ColorIndex = 1
message = InputBox("veuillez recommencer")
If message = "" Then Exit Sub
If Not IsDate(cell) Or cell.NumberFormatLocal <> "jj/mm/aaaa" Or Right(cell, 4) < "2000" Then
cell.Value = message
cell.Font.ColorIndex = 1
cell.Interior.ColorIndex = 0
Exit Do
End If
Loop
End If
Next
Merci pour votre aide