How can I "Select a range"

  • Thread starter Thread starter nguyenxuanson
  • Start date Start date
N

nguyenxuanson

Dear users of the news group, I will try my best to describe my problem

I want to write a macro whose NAME is MY_MACRO which will be called
after I have selected a certain range in a ExcelSheet, say [B5:D10].
This Macro will have to proceed the data contained in the range.

My question is how can I access this range? Is this ActiveRange object?

Best regards
XS
 
Sub MY_MACRO()

With Selection
'do your stuff
End With

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
selection

for example

If typename(selection) = "Range" then
msgbox Selection.Address(external:=True)
End If
 
do you know how can I copy this selected region and paste it exactly as
it is seen to a Outlook application?
XS
 
Dear Tom and Bob
Because my Selection is a Range, I would like to have another question:
how can I access the left most, top cell of the range, and how can I
use RELATIVE reference to access other cells from this top left most
cell.
Best regards.
XS
 
Selection.Cells(1,1)

is the top-left cell

selection.cells(1,1).cells(10,10).select

is one example that gets 10 rows, 10 columns off that cell, or

Selection.Cells(1,1).Offset(11,11).Select

does exactly the same using OFFSET.

And finally, here is a neat little trick I saw Tom post a while back

selection(selection.count).select

which gets the last cell in a selection.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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