![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Apr 2002
Location: Manchester UK
Posts: 133
|
I know it can be done and its probably really easy but does anyone know how to get to the next clear cell in a column, and select it. For example
Sub NextClearCell() Range("A1").Select Selection.End(xlDown).Select End This will take me to the last cell with something in but how do i get to the next empty cell??? |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Hi
Maybe this? Sub NextClearCell() Range("A1").Select Selection.End(xlDown).Activate Range("A" & ActiveCell.Row + 1).Select End Sub Tom [ This Message was edited by: TsTom on 2002-04-25 05:03 ] |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Apr 2002
Location: Manchester UK
Posts: 133
|
it just selects A1?? rather than the botom of the table
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Location: Where the wild roses grow
Posts: 285
|
Try this:
Application.Goto Reference:="R65536C1" Selection.End(xlUp).Select |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Sub NextClearCell()
Dim LastRow NextRow = Range("a1:a" & Range("A65536").End(xlUp).Row).Rows.Count + 1 Cells(NextRow, 1).Select End Sub Joe, I tried yours and it selects the last used cell of the range. This one does work. |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Apr 2002
Location: Manchester UK
Posts: 133
|
cheers for your help so far but when i tried to change this code so it works on column E instead of A it will find the next clear row but selects the next clear row in column A even if the data is in E
This is what i changed from Sub NextClearCell() Dim LastRow NextRow = Range("a1:a" & Range("A65536").End(xlUp).Row).Rows.Count + 1 Cells(NextRow, 1).Select End Sub to Sub NextClearCell() Dim LastRow NextRow = Range("E1:E" & Range("E65536").End(xlUp).Row).Rows.Count + 1 Cells(NextRow, 1).Select End Sub |
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Apr 2002
Location: Manchester UK
Posts: 133
|
Can anyone help????
|
|
|
|
|
|
#8 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Sub NextClearCell()
Dim LastRow NextRow = Range("E1:E" & Range("E65536").End(xlUp).Row).Rows.Count + 1 Cells(NextRow, 5).Select End Sub Culprit = Cells(NextRow, 1).Select where 1 = column 1 change to 5 Tom |
|
|
|
|
|
#9 |
|
Board Regular
Join Date: Apr 2002
Location: Manchester UK
Posts: 133
|
Thanks TsTom that works wonders it also works if you replace the column reference number (After [NextRow, #]) with the letter in "" e.g. "E". Just incase anyone ever needs this, because it is really useful!!
Sub NextClearCell() Dim LastRow NextRow = Range("E1:E" & Range("E65536").End(xlUp).Row).Rows.Count + 1 Cells(NextRow, "E").Select End Sub |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|