ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Prompt user to select a range (https://www.excelbanter.com/excel-programming/419324-prompt-user-select-range.html)

Aaron Dyck

Prompt user to select a range
 
I am writing an add-in that loads a form when a certain toolbar item (That I
have created) is pressed. In this form, there is a textbox for a range. I
need to be able to have the user select the range, much like in the Goal Seek
menu, where the range can be hilighted and dynamically updates the content of
the textbox.

My goal is to have the user select a range, and the macro would then perform
a function on that range.

Any suggestions?

Incidental

Prompt user to select a range
 
Hi Aaron

You could use the refedit control, it should work for what your
after. To use it you will need to add it to your toolbox you can do
this by right clicking the userform toolbox selecting additional
controls and then finding RefEdit.Ctrl and checking it. Then select
the tool and place it on your userform, it works just like the goal
seek selection method.

Hope this helps

Steve


Anant Basant

Prompt user to select a range
 

Hi Aaron,

The code snippet you can use to do such a thing is:

Private Sub CmdOK_Click()

Dim r As Range
On Error Resume Next
Set r = Range(RefEdit1.Value)
If Err.Number < 0 Then
MsgBox "wrong value for range", vbCritical, "Wrong Range"
End If
On Error GoTo 0
End Sub

Once the range is set, it can be used further in the macro.



"Incidental" wrote:

Hi Aaron

You could use the refedit control, it should work for what your
after. To use it you will need to add it to your toolbox you can do
this by right clicking the userform toolbox selecting additional
controls and then finding RefEdit.Ctrl and checking it. Then select
the tool and place it on your userform, it works just like the goal
seek selection method.

Hope this helps

Steve




All times are GMT +1. The time now is 12:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com