Help!
This may be a simple answer but I'm really struggling as I am quite new to vba.
Basically, I have an invoice value and a supplier ID on one sheet and I am trying to write a macro to lookup an invoice number relating to the value and supplier ID on another sheet. All the supplier ID's that I am interested in start with the value 3.
The way I am doing it is I am starting at the top of a list, and doing a while loop to work through the list until the value in the invoice column is nothing.
fvalue = invoice value
svalue = supplier ID
On another sheet I have the invoices listed with supplier ID and invoice amounts and I am trying to search for the value in this sheet. Once it has found the value I want it to check that it is the correct supplier ID. If it is then I want it to copy the cell in the same row column C and paste it next to the data in the original sheet.
Here is the code.
Sub FuelINV()
Sheets("GL").Select
Range("K2").Select
While Not (ActiveCell(1, 2).Value = "")
If Left(ActiveCell(1, 3), 1) = 3 Then
fvalue = Application.Round((-ActiveCell(1, 2).Value * 1.2), 2)
svalue = ActiveCell(1, 3).Value
Sheets("BIFF").Select
Cells.Select
Selection.Find(What:=fvalue, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
If ActiveSheets(ActiveCell.Row, 3) = svalue Then
ActiveCell(1, 2).Copy (Sheets("GL").Range("Q3"))
End If
Sheets("GL").Select
Else
ActiveCell(2, 1).Select
End If
Wend
End Sub
This is the part that isnt working:
If ActiveSheets(ActiveCell.Row, 3) = svalue Then
ActiveCell(1, 2).Copy (Sheets("GL").Range("Q3"))
I am using Range at the minute because I can't work out how to paste it back to the respective row.
Please Help!
Thanks!
Bookmarks