I have a worksheet and it has so many rows
I want when I open the workbook goes to last used cell in a column.
I tried this but it works only manual:
I put it here but not work
Any suggestions are wellcome
I have a worksheet and it has so many rows
I want when I open the workbook goes to last used cell in a column.
I tried this but it works only manual:
I put it here but not work
Any suggestions are wellcome
Re: Last Used Cell
It's xlDown not xlToDown. Btw this will only find the last cell if there are no blanks, otherwise best to start at the bottom and work up.
Re: Last Used Cell
Hi
this will identify the last used cell
The Row & Column numbers associated with the last cell can be found by
Each assumes that the variables have been properly declared.
HTH
Robert
Re: Last Used Cell
I have coded this and it's work?
[VBA]
Sub LastCellAfterUsedInColumn()
Dim Lastrow As Range
Set Lastrow = Range("A3").End(xlDown)
Application.Goto Reference:=Lastrow, Scroll:=True
End Sub
[/vba]
Re: Last Used Cell
Quote from globalStarDisplay MoreI have coded this and it's work?
[VBA]
Sub LastCellAfterUsedInColumn()
Dim Lastrow As Range
Set Lastrow = Range("A3").End(xlDown)
Application.Goto Reference:=Lastrow, Scroll:=True
End Sub
[/vba]
You will see the problem with this method if you do this:
Enter some text or numbers in A1:A5
Skip A6
Enter some text or numbers in A7:A10
Run your code.
Where are you?
Place the cursor back in A1.
Now run Roy's code on the same sheet.
Now where are you?
Roy's method will work correctly as he is going to the last row, first column using the Cells(Rows.Count,1) code. This will go to the bottom of 2003 and 2007 worksheets, even though they have different numbers of rows.
Quote from RoyUKWhy not
[VBA]
Sub LastCellAfterUsedInColumn() Cells(Rows.Count,1).End(xlUp).Select End Sub
[/vba]
The FIND method listed elsewhere in this thread is also a better solution than the code you posted.
Hope this helps,
Don’t have an account yet? Register yourself now and be a part of our community!