Ask a user to select a range in Excel

  • Thread starter Thread starter Ming Ma
  • Start date Start date
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
 
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 (e-mail address removed)
 
Back
Top