VBA Auto fill visible cells

opazzo

Board Regular
Joined
Dec 21, 2005
Messages
69
Office Version
  1. 365
Platform
  1. Windows
Hi there,

Must be something wrong with the syntax as I get a runtime error 1004 : "Autofill method of range class failed".

Here is my code :

Range("X6").FormulaR1C1 = "=IF(ISNA(RC[16]),"""",RC[16])"
Range("X6").AutoFill Destination:=Range("X6:X" & Lastrow).SpecialCells(xlCellTypeVisible)

What I am trying to do is to autofill a formula to a filtered list. Of course I want the formula copied only in the visible cells.

As much as possible I don't want to define my range as a variable, as I need to do the operations on many different columns.

Appreciate some light on this error. Thanks
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Try this...
Code:
Range("X6:X" & Lastrow).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "=IF(ISNA(RC[16]),"""",RC[16])"
 
Upvote 0
Simplify it:
Code:
Range("X6:X" & LastRow).SpecialCells(xlCellTypeVisible).FormulaR1C1 = "=IF(ISNA(RC[16]),"""",RC[16])"
 
Upvote 0

Forum statistics

Threads
1,215,407
Messages
6,124,723
Members
449,184
Latest member
COrmerod

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