Hi!
I'm trying to build an Excel macro that will allow me to do the following:
I have two excel sheets.
I want the macro to match all the values in Sheet1, col A against cell A1 in Sheet2. If it matches, copy cell Dx from Sheet1 to cell D1 in Sheet2, if it doesn't just move on to cell A2 in Sheet2 and do the same, but copy cell Dx from Sheet1 to cell D2.
I tried the vlookup method and I failed.
=vlookup($A1,CELLREF-SHEET1,column(),false)
I'm also trying to implement this method that I've written for another project:
Dim cel As Range, celFound As Range, rg As Range, rgLookHere As Range
Dim i As Long
Dim v As Variant
Set rg = Range("A1") 'First cell to check
Set rgLookHere = rg.Offset(0, 1).EntireColumn 'Check for matches in this column
Set rg = Range(rg, Cells(Rows.Count, rg.Column).End(xlUp))
On Error Resume Next
ReDim v(1 To rg.Cells.Count, 1 To 1)
For Each cel In rg.Cells
i = i + 1
If cel <> "" Then
Set celFound = Nothing
Set celFound = rgLookHere.Find(cel.Value, LookIn:=xlValues, LookAt:=xlWhole)
v(i, 1) = IIf(celFound Is Nothing, "Null", "yes")
End If
Next
rg.Offset(0, 2).Value = v
On Error GoTo 0
Do you have any advice?