Filling down cells with formula, sometiomes their is no data.

Vincent Thank You

New Member
Joined
Oct 3, 2017
Messages
18
Hello!

After filtering for 2017 data in column C the following formula:

With ActiveSheet.Range("N2:N" & Cells(Rows.Count, 2).End(xlUp).Row).SpecialCells(xlCellTypeVisible)
.Cells.FormulaR1C1 = "=IfError((RC[-2]),0)"
.Cells.FillDown
Worksheets("2016").Columns(10).Calculate
End With

runs in the macro. The problem is that sometimes their is no 2017 data and the macro gets hung up and debugs .Cells.FillDown I tried playing around with some if then codes but I can't get it to work properly. Any ideas?
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Code:
On Error Resume Next
[COLOR=#333333]With ActiveSheet.Range("N2:N" & Cells(Rows.Count, 2).End(xlUp).Row).SpecialCells(xlCellTypeVisible)[/COLOR]
[COLOR=#333333].Cells.FormulaR1C1 = "=IfError((RC[-2]),0)"[/COLOR]
[COLOR=#333333].Cells.FillDown[/COLOR]
[COLOR=#333333]Worksheets("2016").Columns(10).Calculate[/COLOR]
[COLOR=#333333]End With[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,265
Members
452,627
Latest member
KitkatToby

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