I need the "Select Data Source" dialog added to my application so that the user can manually select a range (or ranges) in Excel and the range is pasted in my text box. This functionality is everywhere in Excel (most notably when selecting a range for a chart). How can I easily do this?
Yes, but we need to use .NET
Jason
2008-10-28 16:46:05
A:
Dim myRange As Range
On Error Resume Next
Set myRange = Application.InputBox(prompt:="Select the cells you want", Type:=8)
On Error GoTo 0
If myRange Is Nothing Then
MsgBox "User cancelled"
Else
MsgBox "User selected " & myRange.Address
End If
This will show an input dialog. Don't type anything into it, but instead, select cells with the mouse, and their address will appear in the dialog textbox. When you press OK,they should be assigned to the variable myRange.
Notes: The "Type:=8" at the end of the InputBox line tells VBA this must be a range of cells The On Error bit prevents an error if the user cancels
dbb
2008-10-27 02:16:47