macro ne demarre pas

dede

XLDnaute Junior
bonjour a tous encore un souci j ai creer avec l aide du forum cette macro dans un classeur a 3 feuilles menu articles param
probleme elle fonction quand je suis sur la feuille articles mais pas quand je suis sur la feuille menu et je voudrau quel marche sur la feuille MENU ou est l erreur
Dim I As Integer
Private Sub CommandButton1_Click()
With Me
.TextBox1 = ""
.TextBox2 = ""
.TextBox3 = ""
.TextBox4 = ""
.TextBox5 = ""
.TextBox6 = ""
.TextBox7 = ""

For I = 1 To Range("A35000").End(xlUp).Row
If Range("B" & I) = .ComboBox1.Text And Range("C" & I) = .ComboBox2.Text Then
.TextBox1 = Range("A" & I)
.TextBox2 = Range("D" & I)
.TextBox3 = Range("E" & I)
.TextBox4 = Range("F" & I)
.TextBox5 = Range("G" & I)
.TextBox6 = Range("H" & I)
.TextBox7 = Range("I" & I)
Exit For
End If
Next I
End With
End Sub

Private Sub UserForm_Initialize()
Me.ComboBox1.RowSource = "ARTICLES!B1:B" & Range("B35000").End(xlUp).Row
Me.ComboBox2.RowSource = "ARTICLES!C1:C" & Range("C35000").End(xlUp).Row
End Sub




Private Sub UserForm_Click()

End Sub
 

Pièces jointes

  • essai.xlsm
    35.6 KB · Affichages: 87
  • essai.xlsm
    35.6 KB · Affichages: 98
  • essai.xlsm
    35.6 KB · Affichages: 101
Dernière édition:

laetitia90

XLDnaute Barbatruc
Re : macro ne demarre pas

bonjour dede
"brut" je dirais comme cela pas testé
With sheets("MENU")
For I = 1 To .Range("A35000").End(xlUp).Row
If Range("B" & I) = .ComboBox1.Text And Range("C" & I) = .ComboBox2.Text Then
.TextBox1 = .Range("A" & I)
.TextBox2 = .Range("D" & I)
.TextBox3 = .Range("E" & I)
.TextBox4 = .Range("F" & I)
.TextBox5 = .Range("G" & I)
.TextBox6 = .Range("H" & I)
.TextBox7 = .Range("I" & I)
ect..
end with
 

laetitia90

XLDnaute Barbatruc
Re : macro ne demarre pas

re, code userform recherche
Code:
Dim i As Byte
Private Sub CommandButton1_Click()
For i = 1 To 7: Controls("Textbox" & i) = "": Next
With Sheets("ARTICLES")
For i = 2 To .Range("a65536").End(xlUp).Row
If .Range("a" & i) = ComboBox1 And .Range("C" & i) = ComboBox2 Then
TextBox1 = .Range("A" & i)
TextBox2 = .Range("D" & i)
TextBox3 = .Range("E" & i)
TextBox4 = .Range("F" & i)
TextBox5 = .Range("G" & i)
TextBox6 = .Range("H" & i)
TextBox7 = .Range("I" & i)
End If
Next i
End With
If TextBox1 = "" Then MsgBox "pas trouve de reference correspondant a la recherche"
End Sub
Private Sub UserForm_Initialize()
With Sheets("ARTICLES"): ComboBox1.List = Range(.[a2], .[a65536].End(xlUp)).Value: End With
With Sheets("ARTICLES"): ComboBox2.List = Range(.[c2], .[c65536].End(xlUp)).Value: End With
End Sub

ps j'ai mis list a la place de rowsourse je deteste rowsource
autrement il faudrait tous revoir travailler avec
Code:
.ListIndex
bien plus simple
revoir alimentation des 2 comboboxs pour quelles soit "lier" bien plus simple pour rechercher
si quelqu'un as le temps de regarder personnellement pas
 

Discussions similaires

Réponses
6
Affichages
281

Membres actuellement en ligne

Statistiques des forums

Discussions
312 453
Messages
2 088 550
Membres
103 881
dernier inscrit
malbousquet