Sorry, I could have been a little more detailed. here is a sample that
shows what I'm talking about:
Sub tryIt()
Dim res As Range
Dim def As Range
Set def = Application.Selection
Set res = Application.InputBox("Select the range of cells",
Type:=8, _
Default:=def.AddressLocal)
MsgBox res.Address
End Sub
The Type:=8 tells it to let the user select a range. The
Default:=def.AddressLocal gets the range the user already has selected.
This way, if the user already has a range selected, they only have to
click OK, but if they initiated the action and didn't realize they
needed to pre-select the range, the InputBox allows to select it.
Also, to make sure your application is robust, you should verify the
type of the Selection before assigning it to the def range object. The
user's current selection could be a chart or an autoshape, either of
which would cause the above sample to throw an error.
Bookmarks