Hi All
I'm having a problem with the code below trying to get the formula correct, I cant get the LastRow1 part correct.
I've tried everything, the first part INDIRECT(""E"" & ROW()) is OK, it's the (INDIRECT(A1:""A"" & LastRow1)) bit I'm having problems with.
Any help would be appreciated
Cheers
Paul
I'm having a problem with the code below trying to get the formula correct, I cant get the LastRow1 part correct.
I've tried everything, the first part INDIRECT(""E"" & ROW()) is OK, it's the (INDIRECT(A1:""A"" & LastRow1)) bit I'm having problems with.
Any help would be appreciated
Cheers
Paul
Code:
Sub match_sales_manager()
Dim r As Range
Dim LastRow As Long
Dim LastRow1 As Long
With Sheet5
LastRow1 = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
'MsgBox LastRow1
With Sheets("Sheet5")
LastRow = .Cells(.Rows.Count, "E").End(xlUp).Row
For Each r In .Range("E1:E" & LastRow)
If r.Value <> "" Then
r.Offset(0, 1).Value = "=VLOOKUP(INDIRECT(""E"" & ROW()),(INDIRECT(A1:""A"" & LastRow1)),3,0)"
End If
Next r
End With
End Sub