View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Die_Another_Day Die_Another_Day is offline
external usenet poster
 
Posts: 644
Default Understanding change events

I think the short answer to your question is to disable events when
firing off your code.
Sub YourSub()
Application.EnableEvents = False
'YourCode
Application.EnableEvents = True
End Sub

HTH

Die_Another_Day

xhat wrote:
Howdy all. I'm dabbling in Excel VB programming, and have been
searching the web for understanding. While I have found much, it only
serves to increase my questions rather than answer them. So, I turn to
the all-powerful Google to shed light on this poor pilgrim's plight.

Here's the set-up: I have a worksheet that has a web query on it. The
query works just the way I need it to work, however, some of the data
it pulls in is "dirty" and causes some calculated cells on the sheet to
output erroneous totals. I have written a small chunk of code which
"cleans" the strings by lopping off bits of the string that aren't
needed. This works just fine.

(For clarity sake, this section describes exactly what I'm doing. I'm
pulling in table data from www.nfl.com, that has team standings. All
the guys in my fantasy league have drafted a set number (5) of teams,
and those teams' point totals for the season are totalled for each guy
to determine a tie-breaker, if necessary. The problem arises toward
the end of the season when nfl.com starts appending little "y's" and
"x's" and what not to division winners, playoff berth clinch, etc.
Since New York Jets now reads xy-New York Jets (I told you it was
fantasy) for example, the point totals for the Jets are not picked up
in my formula for the guy who owns the Jets. I have to remove "xy-"
from the name, then all is well.)

My goal is to have the macro that handles cleaning the strings be
automatically fired by the "Refresh Data" event. I've been looking at
the Change event, but my concern is that I'll put myself into a
never-ending loop as the macro "changes" the cell after refreshing,
thus triggering the macro, thus... you get the idea. I don't have an
understanding of the underlying functionality of change events and was
hoping someone could point me toward a good resource, or better yet,
give me the cliff notes on change events.

thanks