Bien le bonjour à tous
Si possible je désirerai avoir des explications sur un code en particulier:
Code placé sur Feuille:
Private Sub CommandButton1_Click()
' Commentaires
On Error Resume Next
For Each cel In Range("B1:B" & Range("B5000").End(xlUp).Row)
Attente.Add CStr(cel.Value), CStr(cel.Value)
Next
On Error GoTo 0
'affichage
For i = 1 To Attente.Count - 1
Cells(i + 1, 15) = Attente(i + 1)
Cells(i + 1, 16).FormulaR1C1 = "=conca(RC[-1])"
Next
Set Attente = Nothing
' UO Concernées
On Error Resume Next
For Each cel In Range("B1:B" & Range("B5000").End(xlUp).Row)
Attente.Add CStr(cel.Value), CStr(cel.Value)
Next
On Error GoTo 0
'affichage
For j = 1 To Attente.Count - 1
Cells(j + 1, 15) = Attente(j + 1)
Cells(j + 1, 17).FormulaR1C1 = "=conca2(RC[-2])"
Next
Set Attente = Nothing
End Sub
Code placé sur module
Function conca(titre As String)
Application.Volatile
For Each cel In Range("b2:b" & Range("b5000").End(xlUp).Row)
If cel = titre And InStr(conca, Cells(cel.Row, "I")) = 0 Then
conca = conca & Cells(cel.Row, "I") & " ; "
End If
Next
conca = Left(conca, Len(conca) - 2)
End Function
Function conca2(titre As String)
Application.Volatile
For Each cel In Range("b2:b" & Range("b5000").End(xlUp).Row)
If cel = titre And InStr(conca2, Cells(cel.Row, "H")) = 0 Then
conca2 = conca2 & Cells(cel.Row, "H") & " ; "
End If
Next
conca2 = Left(conca2, Len(conca2) - 2)
End Function
Je suis assez, pas mal, beaucoup novice en langage VBA. Je me suis donc fais aider pour réaliser ce code qui fonctionne trés bien. Il me permet sur une Feuille1 de regrouper sans doublons une série d'information m’étant trés utile. Par contre:
Quelqu'un pourrait-il m'expliquer ce code? De façons "car je galère" à pouvoir l'appliquer sur une feuille2. Je ne parviens pas à le faire.
Faut-il recréer 2 fonctions " conca 3 et 4 "? Dsl si j'en demande beaucoup ...
Voilà le code que j'ai tenté de modifier pour application sur feuille2
sur feuille2
Private Sub CommandButton1_Click()
' Commentaires
On Error Resume Next
For Each cel In Range("B1:B" & Range("B5000").End(xlUp).Row)
Attente.Add CStr(cel.Value), CStr(cel.Value)
Next
On Error GoTo 0
'affichage
For i = 1 To Attente.Count - 1
Cells(i + 1, 15) = Attente(i + 1)
Cells(i + 1, 16).FormulaR1C1 = "=conca3(RC[-1])"
Next
Set Attente = Nothing
' UO Concernées
On Error Resume Next
For Each cel In Range("B1:B" & Range("B5000").End(xlUp).Row)
Attente.Add CStr(cel.Value), CStr(cel.Value)
Next
On Error GoTo 0
'affichage
For j = 1 To Attente.Count - 1
Cells(j + 1, 15) = Attente(j + 1)
Cells(j + 1, 17).FormulaR1C1 = "=conca4(RC[-2])"
Next
Set Attente = Nothing
end sub
et sur module
Function conca3(titre As String)
Application.Volatile
For Each cel In Range("b2:b" & Range("b5000").End(xlUp).Row)
If cel = titre And InStr(conca3, Cells(cel.Row, "I")) = 0 Then
conca3 = conca3 & Cells(cel.Row, "I") & " ; "
End If
Next
conca3 = Left(conca3, Len(conca3) - 2)
End Function
Function conca4(titre As String)
Application.Volatile
For Each cel In Range("b2:b" & Range("b5000").End(xlUp).Row)
If cel = titre And InStr(conca4, Cells(cel.Row, "H")) = 0 Then
conca4 = conca4 & Cells(cel.Row, "H") & " ; "
End If
Next
conca4 = Left(conca4, Len(conca4) - 2)
End Function
Merci à l'avance pour toute personne me venant en aide
Petit détail important ou pas. Les deux boutons ne sont pas les mêmes. Chaque feuille à son bouton propre
Si possible je désirerai avoir des explications sur un code en particulier:
Code placé sur Feuille:
Private Sub CommandButton1_Click()
' Commentaires
On Error Resume Next
For Each cel In Range("B1:B" & Range("B5000").End(xlUp).Row)
Attente.Add CStr(cel.Value), CStr(cel.Value)
Next
On Error GoTo 0
'affichage
For i = 1 To Attente.Count - 1
Cells(i + 1, 15) = Attente(i + 1)
Cells(i + 1, 16).FormulaR1C1 = "=conca(RC[-1])"
Next
Set Attente = Nothing
' UO Concernées
On Error Resume Next
For Each cel In Range("B1:B" & Range("B5000").End(xlUp).Row)
Attente.Add CStr(cel.Value), CStr(cel.Value)
Next
On Error GoTo 0
'affichage
For j = 1 To Attente.Count - 1
Cells(j + 1, 15) = Attente(j + 1)
Cells(j + 1, 17).FormulaR1C1 = "=conca2(RC[-2])"
Next
Set Attente = Nothing
End Sub
Code placé sur module
Function conca(titre As String)
Application.Volatile
For Each cel In Range("b2:b" & Range("b5000").End(xlUp).Row)
If cel = titre And InStr(conca, Cells(cel.Row, "I")) = 0 Then
conca = conca & Cells(cel.Row, "I") & " ; "
End If
Next
conca = Left(conca, Len(conca) - 2)
End Function
Function conca2(titre As String)
Application.Volatile
For Each cel In Range("b2:b" & Range("b5000").End(xlUp).Row)
If cel = titre And InStr(conca2, Cells(cel.Row, "H")) = 0 Then
conca2 = conca2 & Cells(cel.Row, "H") & " ; "
End If
Next
conca2 = Left(conca2, Len(conca2) - 2)
End Function
Je suis assez, pas mal, beaucoup novice en langage VBA. Je me suis donc fais aider pour réaliser ce code qui fonctionne trés bien. Il me permet sur une Feuille1 de regrouper sans doublons une série d'information m’étant trés utile. Par contre:
Quelqu'un pourrait-il m'expliquer ce code? De façons "car je galère" à pouvoir l'appliquer sur une feuille2. Je ne parviens pas à le faire.
Faut-il recréer 2 fonctions " conca 3 et 4 "? Dsl si j'en demande beaucoup ...
Voilà le code que j'ai tenté de modifier pour application sur feuille2
sur feuille2
Private Sub CommandButton1_Click()
' Commentaires
On Error Resume Next
For Each cel In Range("B1:B" & Range("B5000").End(xlUp).Row)
Attente.Add CStr(cel.Value), CStr(cel.Value)
Next
On Error GoTo 0
'affichage
For i = 1 To Attente.Count - 1
Cells(i + 1, 15) = Attente(i + 1)
Cells(i + 1, 16).FormulaR1C1 = "=conca3(RC[-1])"
Next
Set Attente = Nothing
' UO Concernées
On Error Resume Next
For Each cel In Range("B1:B" & Range("B5000").End(xlUp).Row)
Attente.Add CStr(cel.Value), CStr(cel.Value)
Next
On Error GoTo 0
'affichage
For j = 1 To Attente.Count - 1
Cells(j + 1, 15) = Attente(j + 1)
Cells(j + 1, 17).FormulaR1C1 = "=conca4(RC[-2])"
Next
Set Attente = Nothing
end sub
et sur module
Function conca3(titre As String)
Application.Volatile
For Each cel In Range("b2:b" & Range("b5000").End(xlUp).Row)
If cel = titre And InStr(conca3, Cells(cel.Row, "I")) = 0 Then
conca3 = conca3 & Cells(cel.Row, "I") & " ; "
End If
Next
conca3 = Left(conca3, Len(conca3) - 2)
End Function
Function conca4(titre As String)
Application.Volatile
For Each cel In Range("b2:b" & Range("b5000").End(xlUp).Row)
If cel = titre And InStr(conca4, Cells(cel.Row, "H")) = 0 Then
conca4 = conca4 & Cells(cel.Row, "H") & " ; "
End If
Next
conca4 = Left(conca4, Len(conca4) - 2)
End Function
Merci à l'avance pour toute personne me venant en aide
Petit détail important ou pas. Les deux boutons ne sont pas les mêmes. Chaque feuille à son bouton propre
Pièces jointes
Dernière édition: