VBA - Vlookup
Post date: May 17, 2011 9:24:32 PM
' vlookup account
Set range_account = Sheets("account").Range("A:C")
ResultsA = Application.Vlookup(Sheets("salesreport").Cells(a, 1).Value, range_account, 2, False)
If Not IsError(ResultsA) Then
Sheets("result").Cells(a, 4).Value = ResultsA
Else
t = t + 1
MsgBox "Please check the Sales Report on the row " & " " & a & " " & Chr(13) & _
"Missing Account" & " " & Sheets("salesreport").Cells(a, 1).Value _
& " " & "on the sheets Account ", 0 + 64, "result"
Sheets("result").Range(Cells(2, 1), Cells(65536, 15)).Clear
Sheets("output").Select
Sheets("output").Range(Cells(1, 1), Cells(65536, 15)).Clear
Sheets("salesreport").Select
Sheets("salesreport").Cells(a, 1).Select
Exit Sub
End If