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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
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
 
Upvote 0
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?
 
Upvote 0
I've subsequently found that the functionality I'm after is provided by a control: refedit. Which is nice.
 
Upvote 0

Forum statistics

Threads
1,217,482
Messages
6,136,905
Members
450,030
Latest member
Adalinda

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
Back
Top