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).

 
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

It is actually a bit slow, how about the classic loop, while your code goes through all the cells, this loop only does it with the cells with data. And it always selects the proper blank cell too.

Code:
Private Sub Workbook_Open()
    i = 1
    Do While Cells(i, "A").Value <> ""
        i = i + 1
    Loop
    Range("A" & i).Select
End Sub
 
Upvote 0

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
It is actually a bit slow, how about the classic loop, while your code goes through all the cells, this loop only does it with the cells with data. And it always selects the proper blank cell too.

Code:
Private Sub Workbook_Open()
    i = 1
    Do While Cells(i, "A").Value <> ""
        i = i + 1
    Loop
    Range("A" & i).Select
End Sub
You may not have noticed as yet, but I tend to favor compact code and I have a strong leaning toward one-liners. With that said...
Code:
[table="width: 500"]
[tr]
	[td]Private Sub Workbook_Open()
  Cells(Evaluate(Replace("MIN(IF(A1:A#="""",ROW(A1:A#)))", "#", Cells(Rows.Count, "A").End(xlUp).Row + 1)), "A").Select
End Sub[/td]
[/tr]
[/table]
 
Upvote 0
You may not have noticed as yet, but I tend to favor compact code and I have a strong leaning toward one-liners. With that said...
Code:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Private Sub Workbook_Open()
  Cells(Evaluate(Replace("MIN(IF(A1:A#="""",ROW(A1:A#)))", "#", Cells(Rows.Count, "A").End(xlUp).Row + 1)), "A").Select
End Sub[/TD]
[/TR]
</tbody>[/TABLE]

Yes I have noticed that.
I also like to compact the code, as far as my knowledge reaches.
This line is faster, thanks for sharing.
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,487
Members
448,967
Latest member
visheshkotha

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