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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
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,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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