Recherche avec deux critères en VBA Excel

s'il vous plait puis-je obtenir une méthode de recherche avec deux critères ?

- je veux rechercher par le numéro d’rge (N° RGE) mais il y a les mêmes chiffres en double sur la liste et la différence entre eux est la (Divsion)

je veux ça sur le formulaire

quand je mets le numéro d’RGE et mettre la lettre de la division il me donne-les données de l article que je recherche

Je ne peux pas uploader le fichier sur le site

https://www.cjoint.com/c/GHormszkIYt

Bonjour,

à tester,

x1 = "A"
x2 = 1
match_formula = "=MATCH(""" & x1 & """&" & x2 & ", $C:$C&$D:$D, 0)"
result = Evaluate(match_formula)
arcticle = Sheets("BASE").Cells(result, 5)

Re...

je mets ça dans le formulaire ou dans une macro

qu'est ce que ça veut dire -( x1 = "A")- (x2 = 1) je ne la comprends pas

---- merci pour votre attention---

Bonjour,

quand je mets le numéro d’RGE

ComboBox13?

et mettre la lettre de la division

ComboBox14 ?

il me donne-les données de l article que je recherche

on met le résultat à quel endroit ?

bonsoir

Dans le TextBox1 ;2 ; ComboBox1 ; le TextBox3 ;4 ;5 ;6 ;7 ;8 ;9

pour que je puis modifier tous les données

merci encore une fois pour votre aide

Bonjour,

à tester,

Private Sub ComboBox1_Change()
If Me.TextBox2 = "" Then
    MsgBox "Vous devez renseigner le TB2(N° RGE)"
    Exit Sub
Else
    x1 = Me.ComboBox1
    x2 = CInt(Me.TextBox2)
    match_formula = "=MATCH(""" & x1 & """&" & x2 & ", $C:$C&$D:$D, 0)"
    result = Evaluate(match_formula)
    Me.TextBox1 = Sheets("BASE").Cells(result, 2)
    Me.ComboBox2 = Sheets("BASE").Cells(result, 5)
    For i = 3 To 9
     Me.Controls("TextBox" & i) = Sheets("BASE").Cells(result, i + 3)
    Next
End If
End Sub

bonjour

désolé pour le désagrément, mais il y a un problème

a chaque fois que je j ai appuyé sur un bouton il mon envoyer ver le développeur

Private Function My_text()
TextBox1.Text = ActiveCell.Text
ComboBox1.Text = ActiveCell.Offset(0, 1).Text
ComboBox2.Text = ActiveCell.Offset(0, 3).Text
TextBox3.Text = ActiveCell.Offset(0, 4).Text
TextBox2.Text = ActiveCell.Offset(0, 2).Text
TextBox4.Text = ActiveCell.Offset(0, 5).Text
TextBox5.Text = ActiveCell.Offset(0, 6).Text
TextBox6.Text = ActiveCell.Offset(0, 7).Text
TextBox7.Text = ActiveCell.Offset(0, 8).Text
TextBox8.Text = ActiveCell.Offset(0, 9).Text
TextBox9.Text = ActiveCell.Offset(0, 10).Text

End Function

Private Sub btnFermer_Click()
Dim btnFermer As Integer
btnFermer = MsgBox("åá ÇäÊ ãÊÃßÏ ãä ÇáÎÑæÌ ãä ÇáÈÑäÇãÌ", vbQuestion + vbYesNo, "ÊäÈíå ÈÇáÎÑæÌ")
If btnFermer = vbYes Then
Unload Me
End If

End Sub

Private Sub CommandButton1_Click()
Dim no_ligne As Integer
no_ligne = ComboBox13.ListIndex + 3
    TextBox1.Value = Cells(no_ligne, 2).Value
    ComboBox1.Text = Cells(no_ligne, 3).Value
    ComboBox2.Text = Cells(no_ligne, 5).Value
    TextBox2.Text = Cells(no_ligne, 4).Value
    TextBox3.Text = Cells(no_ligne, 6).Value
    TextBox4.Text = Cells(no_ligne, 7).Value
    TextBox5.Text = Cells(no_ligne, 8).Value
    TextBox6.Text = Cells(no_ligne, 9).Value
    TextBox7.Text = Cells(no_ligne, 10).Value
    TextBox8.Text = Cells(no_ligne, 11).Value
    TextBox9.Text = Cells(no_ligne, 12).Value

End Sub

Private Sub CommandButton6_Click()
UserForm1.Hide
Feuil2.Range("a1:y26").PrintPreview
End Sub

Private Sub CommandButton7_Click()
UserForm1.Hide
Feuil2.Range("a1:y26").PrintOut
End Sub

Private Sub DERN_Click()
rr = [B65789].End(xlUp).Row
Cells(rr, 2).Select
TextBox1.Text = Cells(rr, 3)
My_text

End Sub

Private Sub Modification_Click()

Dim i As Integer
r = MsgBox("åá ÊÑíÏ ÝÚáÇ ÇáÊÚÏíá Úáì ÇáãáÝ", vbYesNo, "ÊäÈíå")
If r <> 6 Then Exit Sub
For i = 2 To Range("B:B").End(xlDown).Row
If TextBox1.Text = Cells(i, 2) Then
Cells(i, 2) = TextBox1.Text
Cells(i, 3) = ComboBox1.Text
Cells(i, 4) = TextBox2.Text
Cells(i, 5) = ComboBox2.Text
Cells(i, 6) = TextBox3.Text
Cells(i, 7) = TextBox4.Text
Cells(i, 8) = TextBox5.Text
Cells(i, 9) = TextBox6.Text
Cells(i, 10) = TextBox7.Text
Cells(i, 11) = TextBox8.Text
Cells(i, 12) = TextBox9.Text

End If
Next i

End Sub

Private Sub PREC_Click()
If ActiveCell.Offset(-1, 0) = "dddd" Then
MsgBox "åÐÇ Çæá ãÓÌá Ýí ÇáÞÇÆãÉ"
Else
ActiveCell.Offset(-1, 0).Select
My_text
End If

Dim Nblign As Integer
Label8.Caption = Range("B657893").End(xlUp).Row - 2
Nblign = ActiveCell.Row - 2
Label6.Caption = Nblign

End Sub

Private Sub PREM_Click()
Cells(3, 2).Select
TextBox1.Text = Cells(3, 2)
My_text

Dim Nblign As Integer
Label8.Caption = Range("B657893").End(xlUp).Row - 2
Nblign = ActiveCell.Row - 2
Label6.Caption = Nblign

End Sub

Private Sub SUIV_Click()
If ActiveCell.Offset(1, 0) = "" Then
MsgBox "åÐÇ ÇÎÑ ãÓÌá Ýí ÇáÞÇÆãÉ"
Else
ActiveCell.Offset(1, 0).Select
My_text
End If
Dim Nblign As Integer
Label8.Caption = Range("B657893").End(xlUp).Row - 2
Nblign = ActiveCell.Row - 2
Label6.Caption = Nblign

End Sub

Private Sub Suppression_Click()
r = MsgBox("åá ÊÑíÏ ÝÚáÇ ÍÐÝ åÐÇ ÇáãÓÌá ?", vbYesNo, "ÊÍÐíÑ")
If r <> 6 Then Exit Sub
Selection.EntireRow.Delete

End Sub

'****************************************************
'procédure permettant D'afficher toutes les données
'qui a enregistré sur la base de données
'****************************************************
Private Sub UserForm_Initialize()

Sheets("BASE").Activate
Cells(3, 2).Select
TextBox1.Text = Cells(3, 2)
ComboBox1.Text = Cells(3, 3)
TextBox2.Text = Cells(3, 4)
ComboBox2.Text = Cells(3, 5)
TextBox3.Text = Cells(3, 6)
TextBox4.Text = Cells(3, 7)
TextBox5.Text = Cells(3, 8)
TextBox6.Text = Cells(3, 9)
TextBox7.Text = Cells(3, 10)
TextBox8.Text = Cells(3, 11)
TextBox9.Text = Cells(3, 12)

Dim Nblign As Integer
Label8.Caption = Range("B657893").End(xlUp).Row - 2
Nblign = ActiveCell.Row - 2
Label6.Caption = Nblign

End Sub

Private Sub Ajout_Click()
Dim i As Integer
For i = 3 To Range("B:B").End(xlDown).Row
If Cells(i, 3).Text = TextBox1.Text Then MsgBox "Ce Nom est déjà attribué à " & Cells(i, 3).Value: TextBox1.Text = " ": TextBox1.SetFocus: Exit Sub
Next i
For i = 3 To Range("B:B").End(xlDown).Row
Cells(ActiveCell.Row, 2) = TextBox1.Text
Cells(ActiveCell.Row, 3) = ComboBox1.Text
Cells(ActiveCell.Row, 4) = TextBox2.Text
Cells(ActiveCell.Row, 5) = ComboBox2.Text
Cells(ActiveCell.Row, 6) = TextBox3.Text
Cells(ActiveCell.Row, 7) = TextBox4.Text
Cells(ActiveCell.Row, 8) = TextBox5.Text
Cells(ActiveCell.Row, 9) = TextBox6.Text
Cells(ActiveCell.Row, 10) = TextBox7.Text
Cells(ActiveCell.Row, 11) = TextBox8.Text
Cells(ActiveCell.Row, 12) = TextBox9.Text

Next i
End Sub

Private Sub Effacer_Click()
TextBox1.Text = ""
ComboBox1.Text = ""
TextBox2.Text = ""
ComboBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""

[B65675].End(xlUp).Offset(1, 0).Select   '....se placer sur la derniere celluledu tableau

End Sub

Private Sub CommandButton2_Click()
ThisWorkbook.Application.Visible = True
End Sub

Private Sub CommandButton4_Click()
ThisWorkbook.Application.Visible = False
End Sub

Private Sub CommandButton5_Click()
ThisWorkbook.Save
Application.Quit
End Sub

Private Sub ComboBox1_Change()
If Me.TextBox2 = "" Then
    MsgBox "Vous devez renseigner le TB2(N° RGE)"
    Exit Sub
Else
    x1 = Me.ComboBox1
    x2 = CInt(Me.TextBox2)
    match_formula = "=MATCH(""" & x1 & """&" & x2 & ", $C:$C&$D:$D, 0)"
    result = Evaluate(match_formula)
    Me.TextBox1 = Sheets("BASE").Cells(result, 2)
    Me.ComboBox2 = Sheets("BASE").Cells(result, 5)
    For i = 3 To 9
     Me.Controls("TextBox" & i) = Sheets("BASE").Cells(result, i + 3)
    Next
End If
End Sub

Bonjour,

voici une version allégée de votre fichier.

faite varier le ComboBox1 (Divsion) de A à B et de B à A pour voir le résultat

Rechercher des sujets similaires à "recherche deux criteres vba"