last cell in column with empty cells

excellence

Board Regular
Joined
Oct 5, 2005
Messages
133
Office Version
  1. 365
Platform
  1. MacOS
Hi,
How do I change this macro to offset the last cell that has contents by 1 row, EVEN IF some cells in the column may be blank.

So, if column A was:
a1=1
a2=
a3=x
a4=t
a5=re

It would choose a6


Sub lastcell()
Range("A1").End(xlDown).Select
ActiveCell.Offset(1, 0).Select
End Sub

Thanks
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
If there is no other data after A5 use:
VBA Code:
Range("A" & Rows.Count).End(xlUp).Select
 
Upvote 0
VBA Code:
range("A" & (rows.count).end(xlup).row)+1)
 
Upvote 0
As per the example the last data is in A5 (could be wherever). Anyway I had messed up my post #2, now I got it right but you could use only one line of code, like this:
VBA Code:
Sub lastcell()
    Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Select
End Sub
 
Upvote 0
Solution
As per the example the last data is in A5 (could be wherever). Anyway I had messed up my post #2, now I got it right but you could use only one line of code, like this:
VBA Code:
Sub lastcell()
    Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Select
End Sub
Simply perfect
Thanks
 
Upvote 0
Thanks for the positive feedback, glad having been of some help(y).
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,411
Members
449,081
Latest member
JAMES KECULAH

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