Bonjour,
Je d=E9bute en VBA et je cherche une macro, associer =E0 un bouton qui
v=E9rifie si une ligne est bien remplie.
Je m'explique:
j'ai un tableau qui va de A3 =E0 F65536.
j'aimerai associer un bouton qui v=E9rifie que toute les cellules de la
derni=E8re ligne entr=E9e sont remplies.
Pour pouvoir sauvegarder et quitter.
Le code pour sauvegarder et quitter, associer =E0 un bouton, c'est bon.
Mais il me manque la v=E9rification de la ligne.
Merci d'avance, en esp=E9rant que mes explications aient =E9t=E9 claires.
oui c'est bien ça, si la clef de la première entré est toujours '00125 tu pourrais ajouter une autre condition à savoir If target.row = 3 then Range("A3") = "'00125"
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Set isect = Application.Intersect(Target, Range("G3:G65536")) If Not isect Is Nothing Then
If target.row = 3 then Range("A3") = "'00125" <------------------------------------------------
If Application.CountA(Range(Cells(Target.Row, 1), Cells(Target.Row, 6))) = 6 Then Cells(Target.Row + 1, 1) = "'" & (Format(CDbl(Cells(Target.Row, 1)) + 1, "00000")) Cells(Target.Row + 1, 2).Select Else For i = 2 To 6 If Cells(Target.Row, i) = "" Then Cells(Target.Row, i).Select Selection.Interior.ColorIndex = 3 MsgBox ("vous devez remplir toute les cellules de la colonne B à F de cette ligne") Selection.Interior.ColorIndex = xlNone Exit Sub End If Next End If End If End Sub
isabelle
bonjour lograd,
je doit la rentrer comme cela : " '00125 " ?
oui c'est bien ça,
si la clef de la première entré est toujours '00125
tu pourrais ajouter une autre condition à savoir
If target.row = 3 then Range("A3") = "'00125"
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set isect = Application.Intersect(Target, Range("G3:G65536"))
If Not isect Is Nothing Then
If target.row = 3 then Range("A3") = "'00125" <------------------------------------------------
If Application.CountA(Range(Cells(Target.Row, 1), Cells(Target.Row, 6))) = 6 Then
Cells(Target.Row + 1, 1) = "'" & (Format(CDbl(Cells(Target.Row, 1)) + 1, "00000"))
Cells(Target.Row + 1, 2).Select
Else
For i = 2 To 6
If Cells(Target.Row, i) = "" Then
Cells(Target.Row, i).Select
Selection.Interior.ColorIndex = 3
MsgBox ("vous devez remplir toute les cellules de la colonne B à F de cette ligne")
Selection.Interior.ColorIndex = xlNone
Exit Sub
End If
Next
End If
End If
End Sub
oui c'est bien ça, si la clef de la première entré est toujours '00125 tu pourrais ajouter une autre condition à savoir If target.row = 3 then Range("A3") = "'00125"
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Set isect = Application.Intersect(Target, Range("G3:G65536")) If Not isect Is Nothing Then
If target.row = 3 then Range("A3") = "'00125" <------------------------------------------------
If Application.CountA(Range(Cells(Target.Row, 1), Cells(Target.Row, 6))) = 6 Then Cells(Target.Row + 1, 1) = "'" & (Format(CDbl(Cells(Target.Row, 1)) + 1, "00000")) Cells(Target.Row + 1, 2).Select Else For i = 2 To 6 If Cells(Target.Row, i) = "" Then Cells(Target.Row, i).Select Selection.Interior.ColorIndex = 3 MsgBox ("vous devez remplir toute les cellules de la colonne B à F de cette ligne") Selection.Interior.ColorIndex = xlNone Exit Sub End If Next End If End If End Sub