XL 2016 RechercheV en VBA

MR.O

XLDnaute Junior
Bonjour,

Je souhaiterais faire une rechercheV via VBA car j'ai énormémen de ligne (170 000).
L'objectif serait de ramené le résultat de la colonne C (feuil Base) dans la colonne AS, le critère étant CONTENANT en colonne P.

Merci d'avance pour votre aide,

Cordialement,
 

Pièces jointes

  • recherchev VBA.xlsx
    775.4 KB · Affichages: 11
Solution
un test avec ce que j'ai compris
VB:
Sub test()
With Sheets("base")
    tabdata = .UsedRange.Value
End With

With Sheets("EXEMPLE")
    fin = .Range("P" & .Rows.Count).End(xlUp).Row
    For i = 2 To fin
        Contenant = .Range("P" & i)
        For j = LBound(tabdata, 1) To UBound(tabdata, 1)
            If tabdata(j, 2) = Contenant Then
                .Range("AS" & i) = tabdata(j, 3)
                Exit For
            End If
        Next j
    Next i
End With
End Sub

PS: Renommer ta feuille Exemple SANS l'espace à la fin

vgendron

XLDnaute Barbatruc
Bonjour
je ne comprend pas trop.
dans ta feuille Base: le contenant est unique? ou on peut avoir plusieurs fois le meme contenant?
dans ta feuille exemple.. tu as plusieurs fois le meme contenant ??
pourquoi une recherchV ne convient pas? trop lent?
 

vgendron

XLDnaute Barbatruc
un test avec ce que j'ai compris
VB:
Sub test()
With Sheets("base")
    tabdata = .UsedRange.Value
End With

With Sheets("EXEMPLE")
    fin = .Range("P" & .Rows.Count).End(xlUp).Row
    For i = 2 To fin
        Contenant = .Range("P" & i)
        For j = LBound(tabdata, 1) To UBound(tabdata, 1)
            If tabdata(j, 2) = Contenant Then
                .Range("AS" & i) = tabdata(j, 3)
                Exit For
            End If
        Next j
    Next i
End With
End Sub

PS: Renommer ta feuille Exemple SANS l'espace à la fin
 

Discussions similaires

Réponses
3
Affichages
149
Réponses
11
Affichages
434