# Autofilling Formulas in Separate Columns

#### cjvenables

##### Board Regular
Hello,

I have some code that will put formulas into the following ranges in different columns. Since the columns aren't next to each other, I'm looking for some code to autofill them in the last row of each column, aligning with column A.

Code:
``Range("F4,I4,L4,O4,R4,U4,X4,AA4,AD4,AG4,AJ4,AM4").FormulaR1C1 = "=RC[-2]-RC[-1]"``

I tried to make the code an autofill, but I'm getting an error. Hope someone can help me out.

Code:
``Range("F4,I4,L4,O4,R4,U4,X4,AA4,AD4,AG4,AJ4,AM4").AutoFill Destination:=Range("F4:F,I4:I,L4:L,O4:O,R4:R,U4:U,X4:X,AA4:AA,AD4:AD,AG4:AG,AJ4:AJ,AM4:AM" & Range("A" & Rows.Count).End(xlUp).Row)``

Thanks!

### Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try this:

Code:
``````Sub AutoFillNoncontiguous()
lr = Range("A" & Rows.Count).End(xlUp).Row
cols = Array("F", "I", "L", "O", "R", "U", "X", "AA", "AD", "AG", "AJ", "AM") 'your columns
For c = LBound(cols) To UBound(cols)
Range(cols(c) & "4").AutoFill Destination:=Range(cols(c) & "4:" & cols(c) & lr) 'fill
Next c
End Sub``````

Works great!

Thanks for the feedback.

Replies
1
Views
209
Replies
10
Views
489
Replies
1
Views
123
Replies
3
Views
173
Replies
7
Views
165

1,203,075
Messages
6,053,394
Members
444,661
Latest member
liamoohay

### 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.

### Which adblocker are you using?

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

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