Vlookup Macro

bhieatza

New Member
Joined
Apr 27, 2016
Messages
18
I have a Vlookup function that works great but I can not figure out how to get it working in a macro. The function is
=IF(ISNA(VLOOKUP(AU2,Sheet1!F:F,1,0)),"",VLOOKUP(AU2,Sheet1!F:G,2,FALSE))
an it is posted in column AP and copied all the way down. Any suggestions?

Thanks for your help.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Why VBA

why not making a table of your data.

if the data is a table and you add a formula it will automatic fill down to the last row of the list.

=> insert => table
 
Upvote 0
I have 5 conditional drop downs. Based on the result of the 5th drop down(which is text) I need a number that corresponds to that string. I can not add any columns to the existing worksheet.
 
Upvote 0
Try this, where you will adjust AP1 to the row you want the formulas to begin.

Howard


Code:
Option Explicit

Sub Formula_Down()

Dim lRow As Long

lRow = Cells(Rows.Count, "F").End(xlUp).Row
Range("[B]AP1[/B]:AP" & lRow).Formula = "=IF(ISNA(VLOOKUP(AU2,Sheet1!F:F,1,0)),"""",VLOOKUP(AU2,Sheet1!F:G,2,FALSE))"

End Sub
 
Upvote 0
Try changing to the single cell that you have you original formula in that you say works great.

Range("AP1:AP" & lRow).

Like this, or whatever cell it is, and run the macro.

Range("AP1").Formula = "=IF(ISNA(VLOOKUP(AU2,Sheet1!F:F,1,0)),"""",VLOOKUP(AU2,Sheet1!F:G,2,FALSE))"

Does the formula work there?

Howard
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,093
Latest member
catterz66

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