Find first cell then fill the cells until last used row

urobee

Board Regular
Joined
Jan 30, 2015
Messages
98
Hy,


My target is to fill the cells in column B with a formula from the first empty cell for the last used row.

I can fill the cells from a given cell until last used row with this code:

Code:
Dim Lastrow As Long
Lastrow = .Range("A" & Rows.Count).End(xlUp).Row
With shBom
'other parts of the macro
	.Range("C2:C" & Lastrow).FillDown
End With

And I can find the firts empty cell in a row:

Code:
Dim Firstrow As Range
Set Firstrow = shMySheet.Range("B1").End(xlDown).Offset(1, 0)
'other parts of the macro

But how can I combine this two?
(the first and a last used cell is change often so it's not acceptable to set a constant cell address in the code)

Thanks!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Code:
Dim bRng As Range
Set bRng = Range(Firstrow, Cells(Lastrow, "B"))
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,580
Members
449,089
Latest member
Motoracer88

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