Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Changing Cell Text During Change Event

I'm using Excel 2003 and writing some VBA code to validate cell contents.

I'm using the "Worksheet_Change" event to trap when a user modifies the
contents of a cell ($1:$D). If the contents are invalid I want to display a
message in another cell ($1:$C). While stepping through the code I find the
event fires fine, and using the following code my display cell populates fine:

Me.Cells(intRow, 3) = strErrorMessage

And I can see this new text on the screen. However, once that text is
applied again, the "Worksheet_Change" event fires again. The text remains in
there until the end of the first call to the event, then it clears out.

Is anyone aware of a problem modifying the contents of other cells, while in
the middle of the "Change" event of another? Anyone know a work around?

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default Changing Cell Text During Change Event

Can you post your code here? The first thing I would try would be to
disable events after the first event triggers like this:

Sub Worksheet_Change(BlahBlahBlah)
Application.EnableEvents = False
'Your Code
Application.EnableEvents = True
End Sub

HTH

Die_Another_Day

nullGumby wrote:
I'm using Excel 2003 and writing some VBA code to validate cell contents.

I'm using the "Worksheet_Change" event to trap when a user modifies the
contents of a cell ($1:$D). If the contents are invalid I want to display a
message in another cell ($1:$C). While stepping through the code I find the
event fires fine, and using the following code my display cell populates fine:

Me.Cells(intRow, 3) = strErrorMessage

And I can see this new text on the screen. However, once that text is
applied again, the "Worksheet_Change" event fires again. The text remains in
there until the end of the first call to the event, then it clears out.

Is anyone aware of a problem modifying the contents of other cells, while in
the middle of the "Change" event of another? Anyone know a work around?

Thanks.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Changing Cell Text During Change Event

I feel very silly...I guess all you need is another programmer to make you
look at your code again to see a simple syntax error. :)

My "ValidateCell" function was setting the value in the reporting cell...but
it was a function, whose result was populating the reporting cell... I guess
at first I thought a function would be good...but forgot halfway through that
I was using a function. :) Maybe I've been working on this too long.

Thanks for learning me on the "Application.EnableEvents"--that might come in
handy someday.

"Die_Another_Day" wrote:

Can you post your code here? The first thing I would try would be to
disable events after the first event triggers like this:

Sub Worksheet_Change(BlahBlahBlah)
Application.EnableEvents = False
'Your Code
Application.EnableEvents = True
End Sub

HTH

Die_Another_Day

nullGumby wrote:
I'm using Excel 2003 and writing some VBA code to validate cell contents.

I'm using the "Worksheet_Change" event to trap when a user modifies the
contents of a cell ($1:$D). If the contents are invalid I want to display a
message in another cell ($1:$C). While stepping through the code I find the
event fires fine, and using the following code my display cell populates fine:

Me.Cells(intRow, 3) = strErrorMessage

And I can see this new text on the screen. However, once that text is
applied again, the "Worksheet_Change" event fires again. The text remains in
there until the end of the first call to the event, then it clears out.

Is anyone aware of a problem modifying the contents of other cells, while in
the middle of the "Change" event of another? Anyone know a work around?

Thanks.



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
How to run an event upon changing the value of a specific cell? Wael Fathy Excel Worksheet Functions 1 February 23rd 10 02:04 PM
Cell value change to trigger macro (worksheet change event?) Neil Goldwasser Excel Programming 4 January 10th 06 01:55 PM
Change Cell from Validated List Not Firing Worksheet Change Event [email protected] Excel Programming 3 October 4th 04 03:00 AM
Change a cells text by another cell changing. Mike L.[_2_] Excel Programming 1 May 21st 04 10:23 PM
click event for changing cell color liglin Excel Programming 5 April 26th 04 08:46 PM


All times are GMT +1. The time now is 07:32 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"