filling down Vlookup error

jislandhopper

Board Regular
Joined
Jul 23, 2013
Messages
92
Hi,

I made a V-lookup fuction against a cell where is searched different paramenters depending on the calls value. But when I record the marco it doesnt work. The code doesnt fill in or copy down. Can anyone tell me whats wrong?

The cell I want to populate and down is G2:G2000 and the code I have is below. The code works if I type it manually but not if I create a macro and I can't figure out why, can anyone help?

Sheets("UCR Index").Select
Range("G2").Select
ActiveCell.FormulaR1C1 = _
"=IFERROR(IF(RC[-4]>R[-1]C[696],VLOOKUP(RC[-4],'UCR LIST'!R2C[-5]:R2001C[9],15,FALSE),VLOOKUP('UCR Index'!RC[-5],'UCR LIST'!R2C[-6]:R2001C[9],16,FALSE)),"""")"
Range("G2").Select
Selection.FillDown
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Maybe this, with no need to select?


Code:
Sheets("UCR Index").Range("G2:G2000").FormulaR1C1 = _
 "=IFERROR(IF(RC[-4]>R[-1]C[696],VLOOKUP(RC[-4],'UCR LIST'!R2C[-5]:R2001C[9],15,FALSE),VLOOKUP('UCR Index'!RC[-5],'UCR LIST'!R2C[-6]:R2001C[9],16,FALSE)),"""")"

Howard
 
Upvote 0
Howard has posted a simple & efficient method to populate your formulas. However, just to explain why yours wasn't working..

In order to use FillDown you need to specify a range for it to fill down into. The problem is the highlighted line.
Try it again with that line changed to
Code:
Range("G2:G2000").Select


Hi,

I made a V-lookup fuction against a cell where is searched different paramenters depending on the calls value. But when I record the marco it doesnt work. The code doesnt fill in or copy down. Can anyone tell me whats wrong?

The cell I want to populate and down is G2:G2000 and the code I have is below. The code works if I type it manually but not if I create a macro and I can't figure out why, can anyone help?

Sheets("UCR Index").Select
Range("G2").Select
ActiveCell.FormulaR1C1 = _
"=IFERROR(IF(RC[-4]>R[-1]C[696],VLOOKUP(RC[-4],'UCR LIST'!R2C[-5]:R2001C[9],15,FALSE),VLOOKUP('UCR Index'!RC[-5],'UCR LIST'!R2C[-6]:R2001C[9],16,FALSE)),"""")"
Range("G2").Select
Selection.FillDown
 
Upvote 0
Thanks to both of you, can have asked any more anwers works and I now understand the error in my ways. Thanks again
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,797
Members
449,048
Latest member
greyangel23

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