Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default worksheet_change event fires multiple times


I have a cell formated as "h:mm AM/PM". If the user doesn't enter
valid time, they get an error message. If they don't enter a vali
time again, they keep getting the error message until the press Cancel
or enter a valid time.

I'm keeping track of the changes on the spreadsheet using th
worksheet_change event.

When the user enters a valid time the worksheet_change event fires.

If the user had entered an invalid time 2 times, then finally enters
valid time, the worksheet_change event fires 3 times.

Is there an event that would only fire when the user has entered
valid time, and only fire once

--
timconsta
-----------------------------------------------------------------------
timconstan's Profile: http://www.excelforum.com/member.php...fo&userid=1503
View this thread: http://www.excelforum.com/showthread.php?threadid=26650

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default worksheet_change event fires multiple times

If your change event is firing multiple time then your on change event must
be making a change itself. (recursive call) To fix this at the beginning of
the on change event add this

application.enableevents = false

and at the end

application.enableevents = true

when you use code like this it is a good idea to include error handling
which turns events back on in case of an error

Top of sub

On Error Goto ErrorHandler

Bottom of sub

exit sub
ErrorHandler:
application.enableevents = true
application.screenupdating = true
end sub

Hope this helps...

"timconstan" wrote:


I have a cell formated as "h:mm AM/PM". If the user doesn't enter a
valid time, they get an error message. If they don't enter a valid
time again, they keep getting the error message until the press Cancel,
or enter a valid time.

I'm keeping track of the changes on the spreadsheet using the
worksheet_change event.

When the user enters a valid time the worksheet_change event fires.

If the user had entered an invalid time 2 times, then finally enters a
valid time, the worksheet_change event fires 3 times.

Is there an event that would only fire when the user has entered a
valid time, and only fire once?


--
timconstan
------------------------------------------------------------------------
timconstan's Profile: http://www.excelforum.com/member.php...o&userid=15036
View this thread: http://www.excelforum.com/showthread...hreadid=266509


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
worksheet_change event when multiple cells changed (pasted) noddy26 Excel Programming 13 July 24th 04 09:59 PM
Worksheet_change event Dwayne Smith Excel Programming 2 June 5th 04 03:25 AM
Halting the Worksheet_Change event Jim McLeod Excel Programming 2 April 26th 04 02:31 PM
Worksheet_Change Event cmcfalls[_4_] Excel Programming 3 April 12th 04 09:47 PM
Worksheet_Change Event Sam Excel Programming 2 November 21st 03 06:51 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"