Continue formula in entire column, indefinitely

Lifterlady16

New Member
Joined
Aug 14, 2018
Messages
6
I'm very new to VBA and have not found the answer in other posts. Hoping you can assist.

I need the formula provided below to continue past cell 83, as I'm going to be reusing this macro on other data that may be larger than 83 lines. How do I essentially tell it to read ALL cells in the column?

Code:
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Range("L1").Select[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]   ActiveCell.FormulaR1C1 = "Month"[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]   Range("L2").Select[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]   ActiveCell.FormulaR1C1 = "=MONTH"[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]   Range("L2").Select[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]   ActiveCell.FormulaR1C1 = "=MONTH(RC[-2])"[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]   Range("L2").Select[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]    Selection.AutoFillDestination:=Range("L2:L83")[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]   Range("L2:L83").Select[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000][CODE][/COLOR][/SIZE][/FONT]
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
It looks like your formula is referencing column J.
So, I assume that means that we can look at column J to determine exactly how far we need to do down.

Try this:
Code:
Dim lastRow As Long
lastRow = Cells(Rows.Count, "J").End(xlUp).Row


Range("L1").FormulaR1C1 = "Month"
Range("L2:L" & lastRow).FormulaR1C1 = "=MONTH(RC[-2])"
 
Upvote 0
Another way using the activecell you've selected.

If your formula is present in L2 this will fill down to the last cell of data in Column J.

You can modify the "J" in the code to be "A" or any other column as far as you want to go.

Code:
    Range(ActiveCell.Address & ":" & Cells(Cells(Rows.Count, "J").End(xlUp).Row, ActiveCell.Column + 0).Address).Select
    Selection.FillDown
 
Last edited:
Upvote 0
I really like this version with the "filldown". I have multiple formulas to fill down, so this is ideal. I'll give it a shot!
 
Upvote 0
Happy to help!

This forum has helped me so many times when I've been in a bind.

So it's nice to be able to pay it forward when I can. :beerchug:
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,619
Latest member
Shiv1198

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