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

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
77,703
Office Version
  1. 365
Platform
  1. Windows
How about
VBA Code:
Range("b2:B" & Range("A" & Rows.count).End(xlUp).Row).Value = 1
 
Solution

brasqo

New Member
Joined
Jul 10, 2019
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Fluff - You're a gem!
Thanks as always!

Marked as the solution and "liked"..
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
77,703
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Forum statistics

Threads
1,176,078
Messages
5,901,271
Members
434,884
Latest member
ares0027

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