Selecting a range

  • Thread starter Thread starter Avi
  • Start date Start date
A

Avi

Hello,

Looking for a macro that selects a range from a portion of a row which is
the Active Selection to the last non blank row bellow in the same columns as
the Active Selection. The address of the current selection should be
determined by VBA

Thanks a lot


Avi
 
Hi Arvi,

Try:
'=============>>
Public Sub Tester005()
Dim rng As Range
Dim FRow As Long
Dim LRow As Long

FRow = Selection.Row
LRow = Cells(Rows.Count, Selection.Column).End(xlUp).Row

Set rng = Selection.Resize(LRow - FRow + 1)
rng.Select

End Sub
'<<=============
 
Hi Arvi,

Try:
'=============>>
Public Sub Tester005()
Dim rng As Range
Dim FRow As Long
Dim LRow As Long

FRow = Selection.Row
LRow = Cells(Rows.Count, Selection.Column).End(xlUp).Row

Set rng = Selection.Resize(LRow - FRow + 1)
rng.Select

End Sub
'<<=============
 
A single column or the same size as the original selection


Dim TopCell As Range
Dim BotCell As Range

With ActiveSheet
Set TopCell = ActiveCell
Set BotCell = .Cells(.Rows.Count, TopCell.Column).End(xlUp)
'one column
'.Range(TopCell, BotCell).Select
'or maybe multiple columns
'.Range(TopCell, BotCell).Resize(, Selection.Columns.Count).Select
End With
 

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