Worksheet change

  • Thread starter Thread starter Andrew Haycock
  • Start date Start date
A

Andrew Haycock

hi iam developing a report that uses the Private worksheet change
function. the code below i my test code this works but is there a way
that i can disable this the code whilst the report is created (as it
fires all the time as the report is run) and then reinitialise it
after the report is completed.

Sub Worksheet_Change(ByVal target As Range)
MsgBox "Hi"
End Sub

my aim is that the user can select a cell and change thew value then
the worksheet change function will work out if it is above or below
15% of anouther value and then apply the relevent formatting. this bit
i got sorted but need the worksheet change to be disabled up until the
report is built for the user. (user requests report so it is built
loads of times also data changes often)

please any help would be most appriciated

Andy
 
Andrew,

You can disable events with code such as the following:

Application.EnableEvents = False
'
' your code here
'
Application.EnableEvents = True
 
Chip Pearson said:
Andrew,

You can disable events with code such as the following:

Application.EnableEvents = False
'
' your code here
'
Application.EnableEvents = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com (e-mail address removed)

I've tried that but that doesn't solve the problem when the report is
built. i need a way to have the code their but not fired when the
report is built (built using sql to get data from database) then when
it's all done and teh user can see the report teh code is active and
will then and do the stuff i want

eg

user requests report -> report built but worksheet_change not fired
till report built -> report finished user can see it and start
manipulating the report -> worksheet_change fired when user cahnges a
cell value specific cell

Help!!!

Andy
 
Back
Top