ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cancel RefEdit (https://www.excelbanter.com/excel-programming/342530-cancel-refedit.html)

Dr.Schwartz

Cancel RefEdit
 
I have a refedit control on a form. Once the user activates the control I
would like to have an event that checks if a certain sheet is selected. If
false then I want to cancel the action so that the user doesn't get to select
a range and is returned to the form. Can this be done?

Any help is apriciated
The Doctor



Harald Staff

Cancel RefEdit
 
Hi Doc

The Refedit is buggy. Every time I put code into its events it crashes. So
you may try its Change event, but be prepared to consider other solutions,
like in the OK button click instead.

You evaluate it like this:

Dim R as Range
On Error Resume Next
Set R = Range(Refedit1.text)
On Error Goto 0
If R Is Nothing Then
Refedit1.SetFocus
Exit Sub
End If
If R.Parent.Name = "Sheet2" then
Refedit1.SetFocus
Exit Sub
End If
'and whatever exceptions you need here
'and further action here

HTH. Best wishes Harald

"Dr.Schwartz" skrev i melding
...
I have a refedit control on a form. Once the user activates the control I
would like to have an event that checks if a certain sheet is selected. If
false then I want to cancel the action so that the user doesn't get to

select
a range and is returned to the form. Can this be done?

Any help is apriciated
The Doctor






All times are GMT +1. The time now is 01:22 AM.

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