Hi,
I am looking for a solution that would allow you to search for on the column A of 240111 Search File.xlsx the partial correspondence of a column element A of a 240111 Ask File.xlsm sheet and on column B A 240111 Search file.xlsx the Partial correspondence of a column element B of a 24011 ASK File.xlsm sheet. If the two correspondences are found on the same line, it would be necessary to return the value of the column C of the same line of the sheet B in result on column C of the sheet 24011 ASK FILE.XLSM. I did a macro but I can't make him look for concordances so that they are only true if they are found on the same line.
Here is my macro :
Here is the Excel file with the value to search (240111 ASK FILE.xlsm) :
Here is the 240111 SEARCH FILE.xlsx file with the value to found to send the column 3 result (UNIQUEID) in the column 3 of the Excel 240111 ASK FILE.xlsm file
Hope you can help with that ...
Thank you for your help !
Loadlucas
I am looking for a solution that would allow you to search for on the column A of 240111 Search File.xlsx the partial correspondence of a column element A of a 240111 Ask File.xlsm sheet and on column B A 240111 Search file.xlsx the Partial correspondence of a column element B of a 24011 ASK File.xlsm sheet. If the two correspondences are found on the same line, it would be necessary to return the value of the column C of the same line of the sheet B in result on column C of the sheet 24011 ASK FILE.XLSM. I did a macro but I can't make him look for concordances so that they are only true if they are found on the same line.
Here is my macro :
VBA Code:
Sub Inject2facteurs_test()
Dim heureDebut As Double
Dim heureFin As Double
Dim minutes As Integer
Dim secondes As Integer
Dim sh As Worksheet
Dim wbs As String
Dim fCol1 As Range, fCol2 As Range, fCol3 As Range, fCol4 As Range
Dim c As Range
heureDebut = Timer
' Récupérer le nom du classeur à partir de la cellule G1 de la feuille active
wbs = ActiveSheet.Range("G1").Value
' Définir l'objet Worksheet sh en se référant à la première feuille de calcul du classeur spécifié
Set sh = Workbooks(wbs).Worksheets(1)
' Boucle à travers chaque cellule dans la colonne A de la feuille active
With ThisWorkbook.Worksheets("Feuil1")
For Each c In .Range("A1", .Range("A" & Rows.Count).End(xlUp))
' Réinitialiser les objets Range
Set fCol1A = Nothing
Set fCol2B = Nothing
' Recherche de correspondance partielle dans la première colonne de la feuille sh (colonne 1)
Set fCol1A = sh.Columns(1).Find(c.Value, , xlValues, xlPart, , , False)
' Vérifier si la correspondance dans la colonne A de la feuille active a été trouvée
If Not fCol1A Is Nothing Then
' Recherche de correspondance partielle dans la deuxième colonne de la feuille sh (colonne 2)
Set fCol2B = sh.Columns(2).Find(c.Offset(, 1).Value, , xlValues, xlPart, , , False)
' Vérifier si la correspondance dans la colonne B de la feuille active a été trouvée
If Not fCol2B Is Nothing And Not fCol1A Is Nothing Then
' Copier la valeur de la colonne 3 de la feuille sh dans la colonne 3 de la feuille active
c.Offset(, 2).Value = sh.Cells(fCol1A.Row, 3).Value
End If
End If
Next c
End With
heureFin = Timer
dureeEnSecondes = heureFin - heureDebut
' Convertir en minutes et secondes
minutes = Int(dureeEnSecondes / 60)
secondes = dureeEnSecondes - (minutes * 60)
MsgBox "La macro a pris " & minutes & " minutes et " & secondes & " secondes.", vbInformation
End Sub
Here is the Excel file with the value to search (240111 ASK FILE.xlsm) :
Here is the 240111 SEARCH FILE.xlsx file with the value to found to send the column 3 result (UNIQUEID) in the column 3 of the Excel 240111 ASK FILE.xlsm file
Hope you can help with that ...
Thank you for your help !
Loadlucas