#1   Report Post  
Posted to microsoft.public.excel.misc
CWillis
 
Posts: n/a
Default Stuck in a loop

I am using a drop down menu. When an item from the drop down menu is
selected, certain cells are formatted differently. This is done immediately
using:

Private Sub Worksheet_Change(ByVal Target As Range)

Each selection is sent into a seperate sub which first clears any current
formatting and then formats the cells. The problem is that this unformatting
and then formatting continues until I have to hit "esc." Is there a way to
run it only once per selection of the drop down box? Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson
 
Posts: n/a
Default Stuck in a loop

You probably need to disable events while your code runs. E.g,

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
'
' your code here
'
Application.EnableEvents = True
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"CWillis" wrote in message
...
I am using a drop down menu. When an item from the drop down
menu is
selected, certain cells are formatted differently. This is
done immediately
using:

Private Sub Worksheet_Change(ByVal Target As Range)

Each selection is sent into a seperate sub which first clears
any current
formatting and then formats the cells. The problem is that
this unformatting
and then formatting continues until I have to hit "esc." Is
there a way to
run it only once per selection of the drop down box? Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.misc
CWillis
 
Posts: n/a
Default Stuck in a loop

Works great! Thanks Chip.

"Chip Pearson" wrote:

You probably need to disable events while your code runs. E.g,

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
'
' your code here
'
Application.EnableEvents = True
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"CWillis" wrote in message
...
I am using a drop down menu. When an item from the drop down
menu is
selected, certain cells are formatted differently. This is
done immediately
using:

Private Sub Worksheet_Change(ByVal Target As Range)

Each selection is sent into a seperate sub which first clears
any current
formatting and then formats the cells. The problem is that
this unformatting
and then formatting continues until I have to hit "esc." Is
there a way to
run it only once per selection of the drop down box? 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 put a loop in a macro? Khoshravan New Users to Excel 4 May 14th 06 01:22 PM
Loop time seems dependent on unrelated workbook - Why? Richard Excel Worksheet Functions 2 March 30th 06 11:59 PM
Loop gone crazy Dave Peterson Excel Discussion (Misc queries) 4 December 16th 05 03:38 PM
Do Loop Noemi Excel Discussion (Misc queries) 0 December 8th 05 10:43 PM
hysteresis loop olivekim Charts and Charting in Excel 1 October 28th 05 04:22 AM


All times are GMT +1. The time now is 11:44 AM.

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

About Us

"It's about Microsoft Excel"