UserForms ShowModal

Giordano Bruno

Well-known Member
Joined
Jan 7, 2007
Messages
1,350
I have a UserForm which invites the user to select a row number. If the ShowModal property is True, the user is unable to scroll down the sheet. If the ShowModal property is False then he can.

If he chooses an "illegal" row, he is warned and the UserForm reappears.

When the from reappears, if the ShowModal property is False, the code doesn't stop at the point of reappearance of the UserForm, but continues to work with an innapropriate row.

How can I have both the ability to scroll while the form is active and have the code stop while the form is showing.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
I think you can solve this by using a Type 8 InputBox:

Code:
    Dim Rnge As Range
    
    On Error Resume Next
    
    Set Rnge = Application.InputBox(prompt:="Select a Range", Type:=8)
    
    On Error GoTo 0
    
    If Rnge Is Nothing Then Exit Sub
 
Upvote 0
Thanks hatman,

That's an interesting suggestion, but in fact the UserForm takes three separate entries. That's the reason for using a UserForm rather than an InputBox.

As a workaround, I thought of storing a "yes" or "no" in a hidden sheet and stopping or continuing the code based on the status of this cell. It's a bit clunky, but it's all I can think of at the moment.

It's hard to end the code at the showing of the UserForm as there are a number of tests which must be carried out before execution is approved.

Thanks again for you interest.
 
Upvote 0
Hi Norrie,

Thanks for the thought. In fact, I had earlier considered using RefEdit for some functions. It's rather buggy, but the main problem I had was that I wanted the user to select only rows. RefEdit allows the user to select rows and columns and this would be rather confusing when only the rows were acted upon.

I've never found a way of using RefEdit to allow the user to select entire rows only.
 
Upvote 0
I don't think there is a way to restrict what the user selects.

But I can't see why you can't use what the user has selected and 'convert' it in the code to only work with entire rows.
 
Upvote 0
Hi Norrie.

Thanks for your comments. Yes, I could convert it, but I don't want the confusion in the mind of the user. The other problem is that I often want three rows to be selected, a range and a target. It is more convenient for the user to do this in one operation.
 
Upvote 0

Forum statistics

Threads
1,222,697
Messages
6,167,702
Members
452,132
Latest member
Steve T

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