Fancy way of returning an Excel range selection

bigvarn

New Member
Joined
Nov 15, 2005
Messages
4
Hi,

I'm trying to find out about the fancy way that Excel allows you to select a range. This functionality appears in a number of places in Excel.

To better understand what I mean, create a chart, then right-click on it and select "Source Data..." (you may have to click around to invoke the correct menu).

You'll see a picture of your chart, with its data range underneath. To the right of that data range is a button that will collapse the form and allow you to select a range. How do you recreate that functionality in a VBA form?
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Von Pookie

MrExcel MVP
Joined
Feb 17, 2002
Messages
13,686
You can use the inputbox method. It doesn't allow the box to be collapseable, but you can still select and use a range:

Code:
Sub test()
Dim myRng As Range

On Error Resume Next
Set myRng = Application.InputBox("Select a range", Type:=8)

'if cancel button is pressed, code will exit
If myRng Is Nothing Then Exit Sub

MsgBox "You have selected " & myRng.Address

End Sub
 

bigvarn

New Member
Joined
Nov 15, 2005
Messages
4
Not a bad solution at all!

That said, to be able to mimic Excel's built-in method would give it a seriously professional look.

Anyone? Anyone? Bueller?
 

bigvarn

New Member
Joined
Nov 15, 2005
Messages
4
I've subsequently found that the functionality I'm after is provided by a control: refedit. Which is nice.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,120
Messages
5,857,494
Members
431,882
Latest member
saaaaaaaaaaaaaaaaaaaaaa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top