Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Conditional Formatting Not Immediately Refreshing after Macro Exec

I have a worksheet that includes conditional formatting and a button that
executes a macro to clear and update a few of the cells. These cells are not
the ones with the conditional formatting. My problem/issue is that when I
execute the macro the conditional formatted cells are reset to their
pre-conditional format condition. Immediately afterwards I can enter data
into any unrelated cell and the conditional formatting takes effect.
Pressing F9 (recalculate) also would make the conditional formatting
effective. Ive tried adding the 'application.calculate' code to the end of
the macro but it has no impact.

What am I doing, or not doing to cause the conditional formatting to act
this way?

Thanks
- Pat

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Conditional Formatting Not Immediately Refreshing after Macro Exec

Check that you have not got some code being triggered by an event from the
macro you are running. This does all sorts of funny things and not
necessarily what you might expect. The following lines of code
disables/enables events being triggered. It can be inserted as the first and
last lines of a procedure to suppress other events running. But don't forget
to turn it back on in the last line or other events that you do want to run
later will not run.

Application.EnableEvents = False 'To disable
Application.EnableEvents = True 'To enable again
regards,

OssieMac

"Dreiding" wrote:

I have a worksheet that includes conditional formatting and a button that
executes a macro to clear and update a few of the cells. These cells are not
the ones with the conditional formatting. My problem/issue is that when I
execute the macro the conditional formatted cells are reset to their
pre-conditional format condition. Immediately afterwards I can enter data
into any unrelated cell and the conditional formatting takes effect.
Pressing F9 (recalculate) also would make the conditional formatting
effective. Ive tried adding the 'application.calculate' code to the end of
the macro but it has no impact.

What am I doing, or not doing to cause the conditional formatting to act
this way?

Thanks
- Pat

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Conditional Formatting Not Immediately Refreshing after Macro

I tried it with "Application.EnableEvents = True" after macro execution and
found no difference. However, I did find a solution, but not an explanation.
Instead of using a button created via the Control Toobox, I created a button
using the Forms button object. I also added a button to an existing toolbar
and that also work. A lesson learned from this is that interrupts are
controlled differently when using the Control Toolbox objects.

- Pat

"OssieMac" wrote:

Check that you have not got some code being triggered by an event from the
macro you are running. This does all sorts of funny things and not
necessarily what you might expect. The following lines of code
disables/enables events being triggered. It can be inserted as the first and
last lines of a procedure to suppress other events running. But don't forget
to turn it back on in the last line or other events that you do want to run
later will not run.

Application.EnableEvents = False 'To disable
Application.EnableEvents = True 'To enable again
regards,

OssieMac

"Dreiding" wrote:

I have a worksheet that includes conditional formatting and a button that
executes a macro to clear and update a few of the cells. These cells are not
the ones with the conditional formatting. My problem/issue is that when I
execute the macro the conditional formatted cells are reset to their
pre-conditional format condition. Immediately afterwards I can enter data
into any unrelated cell and the conditional formatting takes effect.
Pressing F9 (recalculate) also would make the conditional formatting
effective. Ive tried adding the 'application.calculate' code to the end of
the macro but it has no impact.

What am I doing, or not doing to cause the conditional formatting to act
this way?

Thanks
- Pat

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Conditional Formatting Not Immediately Refreshing after Macro


You would not find any difference setting "Application.EnableEvents = True"
at the end of the procedure unless you set it to false at the start of the
procedure. It is true by default and you need to set it to false at the start
of a procedure to prevent any other events being called inadvertantly and
then setting it to true on the last line of the procedure puts it back to its
default condition.

An easy way to check whether events are being called inadvertantly is during
development put the following line of code as the first line of every event
procedure.

Msgbox "This sub name". Replace this sub name with the name of the sub where
you have located it. If you see the message while another event is being run
then you will know that it has been triggered. After testing I simply comment
it out because it is easy to take the comment out if I do any modifications
later.

Regards,

OssieMac

"Dreiding" wrote:


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
Excel 2007 Conditional formatting not refreshing as it did in 2003 Elardus Excel Discussion (Misc queries) 1 September 24th 09 09:14 PM
Conditional formatting - Not refreshing Rajula Excel Discussion (Misc queries) 2 July 8th 06 09:51 AM
How to exec a commandbar button while cell in edit mode [email protected] Excel Programming 1 July 4th 06 04:11 PM
How do I keep my own formatting for a pivot-chart on refreshing bensellars1212 New Users to Excel 0 June 13th 06 02:32 PM


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