Excel range selection tool/control?

  • Thread starter Thread starter amos
  • Start date Start date
A

amos

Excel has this nifty range selection (in Page Setup/Sheet or Function Wizard)
that allows to select a range with the mouse and the control then shows the
selected range ($A$1:$B$3 for instance). It looks like a textbox with the grid
icon in the corner. Is this control available for VBA programming? Is it
listed/documented anywhere?
 
Make your own... Here is the code. You will need a user form with a text box
in it...

Place this code in a sheet and run the sub test...

Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
UserForm1.TextBox1.Value = Target.Address
End Sub

Sub test()
UserForm1.Show False
End Sub

HTH...
 
You could also use the Application.InputBox method.


Set sRange = Application.InputBox(prompt:= _
"Select the range of cells.", Type:=8)


Gord Dibben Excel MVP
 
If you do decide to use it, be careful, it can be somewhat flaky. Never
embed it within a frame, it really goes awry then.

But it is useful. I think I read a quote from Tushar Mehta somewhere that he
doesn't see how a serious developer can avoid using it!

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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

Back
Top