View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ronald Dodge Ronald Dodge is offline
external usenet poster
 
Posts: 111
Default How stop the navigation to other cells?

You will need to setup a Range object variable and a boolean variable in the
global section of the worksheet object, which then via the ChangeSelection
Event, you will need to run a data validation check. However, be alert for
infinite looping. That's cause even when the code changes the selection
back to the original cell via this event, this event is triggered again,
thus why you need the global [to the module] boolean variable. The first
time the event is triggered, it will see if the boolean variable is "True",
and since it will not be, it will do the data validation check:

If Boolean Then
Boolean = False
Else
If datavalidation is True Then
Set the Range Object to the new selection
Else
Set the boolean variable to True
Via the Range variable, select the original range with the Select
Method
End If
End If

Now if the "Else" part of the above condition is issued, the Change Event
will be triggerred a second time, so early in the code, you will need to
test of the boolean is "True" and if it is, then just set the Boolean
variable to "False" and exit the macro, else run the Data Validation check.

--
Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"Michel" wrote in message
om...
I'm using Excel 2000/win98:
Worksheets("test").OnEntry = subEntry()
Before leaving the sub I want to go and stay in a specified Cell, but
the enter, cursor, home, ... has still to be executed and changes
that!
I tried .previous.select or .offset(0,1).select but this does only
work on ENTER and not on column A nor does it work with the
cursor-movements.

What I even want more is not allowing to leave the active row and
sheet until all cells on that row are filled in as needed or left
total empty. So how do I trigger movement out of 1 row?

Thanks already for reading it.