VLookup Help needed pretty please :)

instanceoftime

Board Regular
Joined
Mar 23, 2011
Messages
103
I want to create a macro and

I would like to:

be able to open an invoice, hit my macro to lookup the item numbers in column A and search a different workbook called "Final" on my desktop (C:\Users\Glen\Desktop) for the same item number in column A. When found I want to take the corresponding price in column H and place it in E of the invoice. I would like to do this for every row of the invoice.
I've found many references of the formula but not how to run down my list and fill in.


Workbook "Final" continuously changes in size

The cell H in "Final" may be blank (at which point go ahead and continue with the next item number in "invoice")

The cell A (item number) in the invoice may not be found in "Final" (at which point go ahead and continue to with next item number in "Invoice" until last )


So in english: start on "Invoice" A1, take that item number and look for it in workbook "Final" and if found take the corresponding value in "Final" H1 and place that value in "Invoice" C1

go to next item number in "Invoice" column A and continue this until last line. I have read 1000 posts but am not understanding the code enough to know if I can adapt it.

having "Final" open or closed isn't an issue (some posts didn't want to have to have the file open ... that isn't an issue here)

Please help I'm seeing vlookup code in my sleep.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
The following formula get's what I need from the first row:

=VLOOKUP(A1,[final.xls]Items!$A$1:$H$28897,8,0)


1st issue: I need this in a macro and to run until last line of current workbook

2nd issue: range is columns A through H however then length is always growing
 
Upvote 0
Maybe this...but you state you want it in "E" of the invoice, then further in the post you state column "C"
Change the letters in red to "C" if they are not the desierd ones

Code:
Sub MM1()
Dim lr As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
Range("[color=red]E[/color]1:[color=red]E[/color]" & lr).Formula = "=VLOOKUP(A1,[final.xls]Items!$A$1:$H$28897,8,0)"
End Sub
 
Last edited:
Upvote 0
Oops correct.... Column E kk I'll run this and get back

Maybe this...but you state you want it in "E" of the invoice, then further in the post you state column "C"
Change the letters in red to "C" if they are not the desierd ones

Code:
Sub MM1()
Dim lr As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
Range("[COLOR=red]E[/COLOR]1:[COLOR=red]E[/COLOR]" & lr).Formula = "=VLOOKUP(A1,[final.xls]Items!$A$1:$H$28897,8,0)"
End Sub
 
Upvote 0
LOL You are a genius :) that works perfectly ..... many thanks. I was making it way harder.

Now... I have a static range specified for "final" .. that range will vary in length as well. How do I do that row count as well?

=VLOOKUP(A1,[final.xls]Items!$A$1:$H$28897,8,0)"
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top