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 (e-mail address removed)
 

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

Top