VBA Locate first open cell in column and autofill specific value down to last row in column A

rplohocky

Active Member
Joined
Sep 25, 2005
Messages
292
Office Version
  1. 365
Platform
  1. Windows
Hello all,
I am looking for code that will look in column Q for the first open cell, fill every cell with "N/A" all the way down to the last populated row in column A. Another words if column A is blank then stop filling in column Q with "N/A".

I've been working with this code but I know I'm missing something.
<code>
Range("AK2:AK" & Cells(rows.Count, "A").End(xlUp).row).SpecialCells(xlCellTypeVisible).Copy _

Range("Q" & rows.Count).End(xlUp).Offset(1).Select
ActiveCell.FormulaR1C1 = "N/A"

</code>

Any help would be great!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Does this do what you want?
Code:
Sub FillQ()
Range("Q:Q").SpecialCells(xlBlanks).Value = "N/A"
End Sub
 
Upvote 0
Does this do what you want?
Code:
Sub FillQ()
Range("Q:Q").SpecialCells(xlBlanks).Value = "N/A"
End Sub

Yes it does, thank you Fluff! I don't really understand how it knows to stop on the correct row but it works as it should. Thanks again!
 
Upvote 0
Glad to help & thanks for the feedback.

The SpecialCells method only works on the UsedRange.
So while the code looks like it will work on the whole of col Q, it's restricted to the UsedRange.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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