Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dear all,
I would like to select a range starting from cell A1, but the ending cell can be any cell on the worksheet. I am not sure how to program this. Can anyone advise? Thanks in advance! Ivan |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is the basic code:
Sub fLastCell() LastRow = Cells(Rows.Count, 1).End(xlUp).Row MsgBox "Last Row Number is " & LastRow, , "" LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column LastCell = Cells(LastRow, LastColumn) End Sub You will need to select a column that has contiguous data for Cells(Rows.Count, ?) and a row that has contiguous data for cells(Columns.count, ?) so that the End( ) function works properly. "Ivan" wrote: Dear all, I would like to select a range starting from cell A1, but the ending cell can be any cell on the worksheet. I am not sure how to program this. Can anyone advise? Thanks in advance! Ivan |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I forgot to select the range:
Sub fLastCell() LastRow = Cells(Rows.Count, 1).End(xlUp).Row MsgBox "Last Row Number is " & LastRow, , "" LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column LastCell = Cells(LastRow, LastColumn).Address 'Also add Address Range("$A$1:" & LastCell).Select End Sub "Ivan" wrote: Dear all, I would like to select a range starting from cell A1, but the ending cell can be any cell on the worksheet. I am not sure how to program this. Can anyone advise? Thanks in advance! Ivan |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks JLGWhiz !
"JLGWhiz" wrote: I forgot to select the range: Sub fLastCell() LastRow = Cells(Rows.Count, 1).End(xlUp).Row MsgBox "Last Row Number is " & LastRow, , "" LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column LastCell = Cells(LastRow, LastColumn).Address 'Also add Address Range("$A$1:" & LastCell).Select End Sub "Ivan" wrote: Dear all, I would like to select a range starting from cell A1, but the ending cell can be any cell on the worksheet. I am not sure how to program this. Can anyone advise? Thanks in advance! Ivan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
dynamic worksheet select | Excel Programming | |||
Using VBA to select dynamic number of rows | Excel Programming | |||
select last cell in a dynamic list using a macro | Excel Discussion (Misc queries) | |||
Dynamic Range with unused formula messing up x axis on dynamic graph | Charts and Charting in Excel | |||
select dynamic range with dynamic start point | Excel Programming |