Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Excel- Getting users Selection

Status
Not open for further replies.

Jooky68

Programmer
Jul 10, 2002
231
US
I am trying to write a little macro that can get the range of the cells in which the user has selected. Is there a built in method for this? The ActiveCell won't work because it has to be a selection.
 
Why not simply playing with the Selection object ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 

Hi,

Take a look at the Worksheet_SelectionChange Event.

Skip,

[glasses] [red]Be advised:[/red]To be safe on the FOURTH, don't take a FIFTH on the THIRD, or...
You might not come FORTH on the FIFTH! [bomb][tongue]
 
The problem with the Worksheet_SelectionChange is that I want the user to be able to decide if they want to run the macro or not. The macro is called from a toolbar button, the user highlights some cells and clicks the toolbar button to run the macro on those selected cells.

In terms of the Selection object, how would I return the range of the highlighted cells?
 
erm

Selection IS a range object - do you not have the excel help file installed ??

Rgds, Geoff

Three things are certain. Death, taxes and lost data. DPlank is to blame

Please read FAQ222-2244 before you ask a question
 
Sorry was looking for a Selection method within Range. Just came across RangeSelection within the Window class which will do what I need.
 
Selection is a property of the APPLICATION object

Technically, you should write

Application.selection.cells

to reference the user selection but you can almost always get away with just

Selection.cells

Rgds, Geoff

Three things are certain. Death, taxes and lost data. DPlank is to blame

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top