Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

next empty cell - but what if cell is already empty?

Status
Not open for further replies.

pendle666

Technical User
Jan 30, 2003
295
GB
Hello

The first thing in my macro is to move to the next empty cell - which I've done using this:

Selection.End(xlDown).Select
Selection.End(xlToLeft).Select
ActiveCell.Offset(1).Select


This works fine if the active cell is occupied with data, but if it's already on the empty cell then it goes all the way to the very bottom and then gives me an error.

Is there any way around this?

Pendle
 
hi,

Then you FIRST test to determine if the cell has a value. If it does, then do your End method. Else you are already in an empty cell.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Righto, thanks. Errm next question, how do I do that?

Thank you!
 
Try the following:
Code:
Range("a1").End(xlDown).Select
ActiveCell.Offset(1).Select
 
depends HOW you use this process. I never use the Select method as you have posted.
Code:
If Trim(Selection.Value) <> "" Then
    Selection.End(xlDown).Select
    Selection.End(xlToLeft).Select
    ActiveCell.Offset(1).Select
End If
'the currect selection is EMPTY


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top