Re : valeur userform dans des tableaux qui grandissent
Bonjour à tous,
J'ai essayé le code dans mon projet en suivant bien l'exemple de JP14. Ci dessous le code. 9a bug et on la message box indique else sans if. pourtant tout y est , dans l'exemple ça marche mais pas sur mon projet. Quelqu'un peux m'aider?
Merci
'--------------------------------------------- ------
' Module : UserForm1/CommandButton2_Click UserFormFormations/CommandButtonValider_Click
' DateTime : 12/03/2009
' Auteur : JP14
' Bouton :Valider
'--------------------------------------------------
Private Sub CommandButtonValider_Click()
Dim ad As String
Dim lig As Long
Dim i As Long
Dim j As Long
Dim cellule As Range
Dim plage As Range
Dim nomfeuille1 As String
' feuille aa
'nomfeuille1 = "AA"
nomfeuille1 = "LCA"
With Sheets(nomfeuille1)
'If TextBox5.Value = "" Then Exit Sub
If TextBoxInvisible.Value = "" Then Exit Sub
'If TextBox5.Value = "TITRE 3" Then
If TextBoxInvisible.Value = "" Then Exit Sub
lig = .Range("a65536").End(xlUp).Row + 1
Call ajoutdonnee(£ligne:=lig, £feuille:=nomfeuille1)
Else
' titre 1 ou 2 on cherche l'intervalle
ad = "a1:a" & .Range("a65536").End(xlUp).Row
'lig = recherchemot(ad, TextBox5.Value, nomfeuille1, 1)
lig = recherchemot(ad, TextBoxInvisible.Value, nomfeuille1, 1)
Set plage = .Range("a" & lig + 1 & ":a" & .Range("a65536").End(xlUp).Row)
j = 0
For Each cellule In plage
If cellule.Value = "" And j = 0 Then j = cellule.Row
'If cellule.Value = "TITRE 2" Or cellule.Value = "TITRE 3" Then
If cellule.Value = "GPM" Or cellule.Value = "OFP" Then
i = cellule.Row
Exit For
End If
Next cellule
' on insère une ligne
.Rows(i).Insert Shift:=xlDown
' on copie à la première ligne disponible
Call ajoutdonnee(£ligne:=j, £feuille:=nomfeuille1)
End If
End With
End Sub