.FillDown command not working (VBA)

cfluegel

New Member
Joined
Nov 22, 2011
Messages
14
Hello and thank you for viewing. I have an issue with a FillDown command in the following VBA code. The formula being entered into BX2 simply formats 3 columns of data into M/D/Y date format. The code is then designed to fill that formula down until the last row of data in the sheet. For some reason I get a runtime error at: Range("BX2:BX" & LastRow).FillDown

When I step in, it runs the formula in BX2 but does not fill down the formula even though there is data in the rows down to BX500 or so.

Code:
    Range("BX2").Select    ActiveCell.FormulaR1C1 = "=RC[-2]&""/""&RC[-1]&""/""&RC[-3]"
    Range("BX2").Select
    Range("BX2:BX" & LastRow).FillDown
    Columns("BX:BX").Select

Any ideas on what would cause the .FillDown command to fail would be greatly appreciated.

Thank you!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Try it without Filldown at all, enter the formula in the whole range at once.

Code:
Range("BX2:BX" & LastRow).FormulaR1C1 = "=RC[-2]&""/""&RC[-1]&""/""&RC[-3]"
 
Upvote 0
Thank you, I rather like that. However I am still getting the runtime error at that code now.

Have to say I'm feeling a bit stumped here.
 
Upvote 0
Most likely that the LastRow variable doesn't contain a valid numerical value.

Can you post the code that assigns a value to the LastRow variable?
 
Upvote 0
Here's the code

Code:
 Dim LastRow As Long
    LastRow = Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
 
Upvote 0
Works for me...Assuming the LastRow variable has a valid numerical value assigned to it.

Maybe a better question is, what is the value of the LastRow variable at the time of the error?
And what is the wording of the error?

When you get the error, make note of the exact error message.C
lick Debug
Hover your mouse over the LastRow Variable, it will tell you it's value.
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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