Forum Discussion
MicrosoftNewbie121
Apr 03, 2024Brass Contributor
VBA Excel - Verify and Paste value if 2 Cells Match
Hello, i would like to verify the match of 2 cell values like "First Name" & "Last Name" from Sheet 2 and verify if it match any value in Sheet 1 if it does match the 2 cells info then copy past 3rd ...
HansVogelaar
Apr 03, 2024MVP
For example:
Sub FillAddress()
Dim m1 As Long
Dim m2 As Long
With Worksheets("Sheet2")
m2 = .Range("A" & .Rows.Count).End(xlUp).Row
End With
With Worksheets("Sheet1")
m1 = .Range("A" & .Rows.Count).End(xlUp).Row
With .Range("C2:C" & m1)
.Formula2 = "=IFERROR(INDEX(Sheet2!$C$2:$C$" & m2 & _
", MATCH(1, (Sheet2!$A$2:$A$" & m2 & _
"=A2)*(Sheet2!$B$2:$B$" & m2 & "=B2), 0)), """")"
.Value = .Value
End With
End With
End Sub