Expand selection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Range(ActiveCell, ActiveCell.End(xlDown)).Select
________________________________________________________________________
 
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
 
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
 
Range(ActiveCell.Offset(1), ActiveCell.Offset(1).End(xlDown).Offset(-1)).Select
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top