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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

footoo

Well-known Member
Joined
Sep 21, 2016
Messages
3,391
Office Version
  1. 2016
Platform
  1. Windows
Code:
Dim bRng As Range
Set bRng = Range(Firstrow, Cells(Lastrow, "B"))
 

urobee

Board Regular
Joined
Jan 30, 2015
Messages
98
Thanks,

I needed to modify your code but it is good for a start!
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,303
Messages
5,836,526
Members
430,437
Latest member
Emilycr

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
Top