Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Expand selection

I need help with a macro that expands the selection from the ActiveCell to
the last populated cell in the same column. For example:

if Cell A10 is the last populated cell in column A, and the ActiveCell is
A2, i want the macro to expand the selection to be from A2 to A10.

The active cell will not necessarily be in column A. So i want the macro to
be valid for use on any column.

I'm using Excel 2003.

Many thanks
Tendresse
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Expand selection

Range(ActiveCell, ActiveCell.End(xlDown)).Select
__________________________________________________ ______________________

"Tendresse" wrote in message
...
I need help with a macro that expands the selection from the ActiveCell to
the last populated cell in the same column. For example:

if Cell A10 is the last populated cell in column A, and the ActiveCell is
A2, i want the macro to expand the selection to be from A2 to A10.

The active cell will not necessarily be in column A. So i want the macro
to
be valid for use on any column.

I'm using Excel 2003.

Many thanks
Tendresse



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Expand selection

That's exactly what i wanted. Thank you very much.

"Vasant Nanavati" wrote:

Range(ActiveCell, ActiveCell.End(xlDown)).Select
__________________________________________________ ______________________

"Tendresse" wrote in message
...
I need help with a macro that expands the selection from the ActiveCell to
the last populated cell in the same column. For example:

if Cell A10 is the last populated cell in column A, and the ActiveCell is
A2, i want the macro to expand the selection to be from A2 to A10.

The active cell will not necessarily be in column A. So i want the macro
to
be valid for use on any column.

I'm using Excel 2003.

Many thanks
Tendresse




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Expand selection

Another related question, please.

How do i resize the selection from both ends (top and bottom)? For example,
if the selection is from A1 to A10, how can i reduce it one cell from the top
and one cell from the bottom, so that it becomes from A2 to A9?

Again i need this macro to be usable for any selection in any other column.

Many thanks in advance
Tendresse

"Vasant Nanavati" wrote:

Range(ActiveCell, ActiveCell.End(xlDown)).Select
__________________________________________________ ______________________

"Tendresse" wrote in message
...
I need help with a macro that expands the selection from the ActiveCell to
the last populated cell in the same column. For example:

if Cell A10 is the last populated cell in column A, and the ActiveCell is
A2, i want the macro to expand the selection to be from A2 to A10.

The active cell will not necessarily be in column A. So i want the macro
to
be valid for use on any column.

I'm using Excel 2003.

Many thanks
Tendresse




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Expand selection

Range(ActiveCell.Offset(1), ActiveCell.Offset(1).End(xlDown).Offset(-1)).Select


--


Gary


"Tendresse" wrote in message
...
Another related question, please.

How do i resize the selection from both ends (top and bottom)? For example,
if the selection is from A1 to A10, how can i reduce it one cell from the top
and one cell from the bottom, so that it becomes from A2 to A9?

Again i need this macro to be usable for any selection in any other column.

Many thanks in advance
Tendresse

"Vasant Nanavati" wrote:

Range(ActiveCell, ActiveCell.End(xlDown)).Select
__________________________________________________ ______________________

"Tendresse" wrote in message
...
I need help with a macro that expands the selection from the ActiveCell to
the last populated cell in the same column. For example:

if Cell A10 is the last populated cell in column A, and the ActiveCell is
A2, i want the macro to expand the selection to be from A2 to A10.

The active cell will not necessarily be in column A. So i want the macro
to
be valid for use on any column.

I'm using Excel 2003.

Many thanks
Tendresse








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Expand selection

It works perfectly. Thanks a million.

Tendresse

"Gary Keramidas" wrote:

Range(ActiveCell.Offset(1), ActiveCell.Offset(1).End(xlDown).Offset(-1)).Select


--


Gary


"Tendresse" wrote in message
...
Another related question, please.

How do i resize the selection from both ends (top and bottom)? For example,
if the selection is from A1 to A10, how can i reduce it one cell from the top
and one cell from the bottom, so that it becomes from A2 to A9?

Again i need this macro to be usable for any selection in any other column.

Many thanks in advance
Tendresse

"Vasant Nanavati" wrote:

Range(ActiveCell, ActiveCell.End(xlDown)).Select
__________________________________________________ ______________________

"Tendresse" wrote in message
...
I need help with a macro that expands the selection from the ActiveCell to
the last populated cell in the same column. For example:

if Cell A10 is the last populated cell in column A, and the ActiveCell is
A2, i want the macro to expand the selection to be from A2 to A10.

The active cell will not necessarily be in column A. So i want the macro
to
be valid for use on any column.

I'm using Excel 2003.

Many thanks
Tendresse






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Expand selection

Sub SelectFirstToLastInColumn()
Set TopCell = Cells(1, ActiveCell.Column)
Set BottomCell = Cells(65535, ActiveCell.Column)

If IsEmpty(TopCell) Then Set TopCell = TopCell.End(xlDown)
If IsEmpty(BottomCell) Then Set BottomCell = BottomCell.End(xlUp)
If TopCell.Row = 65535And BottomCell.Row = 1 Then ActiveCell.Select Else
Range(TopCell, BottomCell).Select
End Sub

"Tendresse" wrote:

I need help with a macro that expands the selection from the ActiveCell to
the last populated cell in the same column. For example:

if Cell A10 is the last populated cell in column A, and the ActiveCell is
A2, i want the macro to expand the selection to be from A2 to A10.

The active cell will not necessarily be in column A. So i want the macro to
be valid for use on any column.

I'm using Excel 2003.

Many thanks
Tendresse

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot expand the selection to entire spreadsheet when sorting Mikki Excel Worksheet Functions 3 April 3rd 23 04:17 PM
Prevent SORT from asking to expand selection in Excel 2007? M. E. Kabay, PhD, CISSP-ISSMP Excel Discussion (Misc queries) 9 September 9th 19 04:13 PM
Expand Selection in Auto filter NM Excel Worksheet Functions 7 December 4th 08 02:00 PM
Expand Selection in Multiple Sheets Salman Excel Discussion (Misc queries) 0 February 9th 07 11:47 AM
Shift+Arrow does not expand selection No_RZN Excel Discussion (Misc queries) 2 May 25th 05 07:49 AM


All times are GMT +1. The time now is 08:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"