AutoFill down to the first non empty cell in a macro again

Bookmaster

Board Regular
Joined
Mar 22, 2014
Messages
85
Office Version
  1. 2021
Platform
  1. Windows
Hi,

I have similar problem like member ECKSELL in his post "AutoFill down to the first non empty cell in a macro".
I want to put macro that fill my range with formula from second row until first empty cell.

For now my macro is like this:

Range("J2").Select
Selection.AutoFill Destination:=Range("J2:J39")
Range("J2:J39").Select
Range("L2").Select
Selection.AutoFill Destination:=Range("L2:L39")
Range("L2:L39").Select
End Sub

I am not sure how long will be my range next time. This time is 39 rows. So I want to put macro that always fill range until first empty cell.

Thanks in advance.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Try

Code:
Sub test()
Dim LR As Long
LR = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
Range("J2").AutoFill Destination:=Range("J2:J" & LR)
Range("L2").AutoFill Destination:=Range("L2:L" & LR)
End Sub
 
Upvote 0
Thank you very much. That is what I was looking for. I tried so many times to make that macro, but I didn't know how.

Thank you again
 
Upvote 0

Forum statistics

Threads
1,215,379
Messages
6,124,610
Members
449,174
Latest member
ExcelfromGermany

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