Ask a user to select a range in Excel

M

Ming Ma

Hi, All:
Can anyone tell me how to write a macro that asks a user to select a range
in excel? then I would like to use values in the selectionfor other
calculation later on.

Thanks
 
C

Chip Pearson

Ming,

Try something like the following:

Dim Rng As Range
On Error Resume Next
Set Rng = Application.InputBox(prompt:="Select a range", Type:=8)
If Rng Is Nothing Then
MsgBox "no range selected"
Else
MsgBox "You selected: " & Rng.Address
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com [email protected]
 
Top