bonjour Groupe
avec votre aide j'ai réussi à faire une macro qui fonctionne assez bien, merci à tous
mon code renvoie une valeur dans la prochaine cellule vide d'une ligne spécifié
j'aimerais que la ligne est un maximum d'espace que je détermine, comme par exemple dans mon fichier à la ligne 5 le maximum est atteint à la colonne AP
mon code actuel est :
Sub premierTour()
ActiveSheet.Unprotect
Dim r As Excel.Range
Dim c As Excel.Range
     
For Each c In Range("D2:J2")
         
If c.Value <> vbNullString Then
'// Arbitrary range, change if needed
Set r = Range("A5:A57").Find(What:=c.Value, lookat:=xlWhole)
             
If Not r Is Nothing Then
                 
If WorksheetFunction.CountIf(r.EntireRow, Range("B2").Value) > 0 Then
MsgBox Range("B2").Value & " Déjà inscrit dans la semaine " & c.Value, vbExclamation, "Error"
Exit Sub
                    
Else
Cells(r.Row, Columns.Count).End(xlToLeft).Offset(, 1).Value = Range("B2").Value
End If
Else
MsgBox "ligne pour semaine " & c.Value & " inexistante", vbExclamation, "Error"
Exit Sub
                
End If
End If
Next
     
Range("A2:J2").ClearContents
ActiveSheet.Protect
End Sub
	
		
			
		
		
	
				
			avec votre aide j'ai réussi à faire une macro qui fonctionne assez bien, merci à tous
mon code renvoie une valeur dans la prochaine cellule vide d'une ligne spécifié
j'aimerais que la ligne est un maximum d'espace que je détermine, comme par exemple dans mon fichier à la ligne 5 le maximum est atteint à la colonne AP
mon code actuel est :
Sub premierTour()
ActiveSheet.Unprotect
Dim r As Excel.Range
Dim c As Excel.Range
For Each c In Range("D2:J2")
If c.Value <> vbNullString Then
'// Arbitrary range, change if needed
Set r = Range("A5:A57").Find(What:=c.Value, lookat:=xlWhole)
If Not r Is Nothing Then
If WorksheetFunction.CountIf(r.EntireRow, Range("B2").Value) > 0 Then
MsgBox Range("B2").Value & " Déjà inscrit dans la semaine " & c.Value, vbExclamation, "Error"
Exit Sub
Else
Cells(r.Row, Columns.Count).End(xlToLeft).Offset(, 1).Value = Range("B2").Value
End If
Else
MsgBox "ligne pour semaine " & c.Value & " inexistante", vbExclamation, "Error"
Exit Sub
End If
End If
Next
Range("A2:J2").ClearContents
ActiveSheet.Protect
End Sub