Thread: Cancel RefEdit
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Harald Staff Harald Staff is offline
external usenet poster
 
Posts: 1,327
Default 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