compteur2 = 1 Dim CellRecherche As Excel.Range Dim MonAdresse 'Recherche de la 1ère cellule contenant le texte Set CellRecherche = Cells.Find(What:=Textbox1.Text, After:=Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) If Not (CellRecherche Is Nothing) Then '*****On Mémorise l'adresse MonAdresse = CellRecherche.Adress do For i = 0 To nbCols '***** La cellule existe '***** en VB ce n'est pas la peine de pointer sur la cellule 'CellRecherche.Columns(i + 1).Activate 'transfert dans la flexgrid With MSFlexGrid3 .Rows = compteur2 + 1 .Col = i .Row = compteur2 .Text = CellRecherche.Columns(i + 1).Value End With Next i compteur2 = compteur2 + 1 CellRecherche.FindNext(CellRecherche) Loop While Not CellRecherche Is Nothing And _ CellRecherche.Address <> MonAddresse Else 'Pas de cellule avec cette valeur MsgBox "Pas de Code correspondant" End If
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questioncompteur2 = 1 Dim CellRecherche As Excel.Range Dim MonAdresse 'Recherche de la 1ère cellule contenant le texte Set CellRecherche = Cells.Find(What:=Textbox1.Text, After:=Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) If Not (CellRecherche Is Nothing) Then '*****On Mémorise l'adresse MonAdresse = CellRecherche.Adress do For i = 0 To nbCols '***** La cellule existe '***** en VB ce n'est pas la peine de pointer sur la cellule 'CellRecherche.Columns(i + 1).Activate 'transfert dans la flexgrid With MSFlexGrid3 .Rows = compteur2 + 1 .Col = i .Row = compteur2 .Text = CellRecherche.Columns(i + 1).Value End With Next i compteur2 = compteur2 + 1 Set CellRecherche.FindNext(CellRecherche) Loop While Not CellRecherche Is Nothing And _ CellRecherche.Address <> MonAddresse Else 'Pas de cellule avec cette valeur MsgBox "Pas de Code correspondant" End If