Get User Selected Range

Talguy picture Talguy · Nov 2, 2010 · Viewed 233.6k times · Source

How can I get a range of cells selected via user mouse input for further processing using VBA?

Answer

Michael picture Michael · Nov 2, 2010

Selection is its own object within VBA. It functions much like a Range object.

Selection and Range do not share all the same properties and methods, though, so for ease of use it might make sense just to create a range and set it equal to the Selection, then you can deal with it programmatically like any other range.

Dim myRange as Range
Set myRange = Selection

For further reading, check out the MSDN article.