Fill a column with a value until last row used

brasqo

New Member
Joined
Jul 10, 2019
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hey all -
I'm sure I am over-thinking the solution to this problem =/

I'm needing to fill in a column with a single value "1" in each cell within the column, until the last used row...

Example:
I have "Header1" in A1, "Header2" in B1..
I have names in cells A2 - A5...
I need cells B2 - B5 to have the value "1"...

I know the following will fill in the entire column with 1's:

VBA Code:
Range(Range("b2"), Range("b2").End(xlDown)).Value = 1

But how can I tell it to only fill value "1" up to and including B5? (note: the sheet has an unknown number of rows monthly, hence why I cant just use a set range)

Thanks in advance.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
How about
VBA Code:
Range("b2:B" & Range("A" & Rows.count).End(xlUp).Row).Value = 1
 
Upvote 0
Solution
Fluff - You're a gem!
Thanks as always!

Marked as the solution and "liked"..
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,930
Members
452,367
Latest member
TePunaBloke

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