Move to first blank cell in a column upon opening workbook

SanFelippo

Board Regular
Joined
Apr 4, 2017
Messages
124
I have hopefully a pretty simple request; I just haven’tcoded anything like this request before so I was hoping you guys could help.
Basically, all I need is some coding that will run uponopening a an excel workbook that will take the user to the first blank cell incolumn A. That’s all.
Any suggestions? (Yes I realize you could just hold controland hit the down arrow, but the people using this workbook are very challengedwhen it comes to excel things, and this is what they want).

 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Code:
Option Explicit


Private Sub Workbook_Open()
    Dim lr As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    Range("A" & lr + 1).Select
End Sub

Place this code ThisWorkbook in the VBE
 
Upvote 0
Check also this way

Code:
Private Sub Workbook_Open()
    Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Select
End Sub
 
Upvote 0
Both work well if the col is populated, but what if the OP wants a cell somewhere within the column, not at the end ???

Code:
Private Sub Workbook_Open()
BC = Range("A1:A" & Rows.Count).Cells.SpecialCells(xlCellTypeBlanks).Row
Range("A" & BC).Select
End Sub
 
Last edited:
Upvote 0
Both work well if the col is populated, but what if the OP wants a cell somewhere within the column, not at the end ???

Code:
Private Sub Workbook_Open()
BC = Range("A1:A" & Rows.Count).Cells.SpecialCells(xlCellTypeBlanks).Row
Range("A" & BC).Select
End Sub
Go to a new, never used worksheet, fill in some values but do not leave any blanks within the data so that the first blank is after the last value... then run your code. The error results because SpecialCells cannot see beyond the worksheet's UsedRange.
 
Upvote 0
Not the fastest code going, but the delay is hardly noticeable on my somewhat slow, older laptop and it always selects the proper blank cell...
Code:
Private Sub Workbook_Open()
  Cells([MIN(IF(A:A="",ROW(A:A)))], "A").Select
End Sub
 
Upvote 0
I know that Rick, that's why I said....
All I was pointing out is the weak point in your code similar to how you pointed out the weak point in the other posted code here. With that said, the code I posted in Message #8 works no matter where the blank cell is located at.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,171
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