#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default slow macto

When this macro listed only 10 sheets, it worked fine & ended with a
single beep. Now that I made it work on 25 sheets, it hangs up for 3
seconds and ends with 7 beeps. I added Application.EnableEvents at the
front and end and it did not help. All sheets have these button names.
Where did I go wrong? excel 97

Sub SetSwitch1()
Dim ws3 As Worksheet
Set ws3 = Worksheets("Sheet1")
ws3.Range("A2").Value = "Switch1"
With Worksheets("Sheet2")
.OptionButton1.Value = True
.OptionButton2.Value = False
.OptionButton3.Value = False
End With
With Worksheets("Sheet3")
.OptionButton1.Value = True
.OptionButton2.Value = False
.OptionButton3.Value = False
End With
With Worksheets("Sheet4")
.OptionButton1.Value = True
.OptionButton2.Value = False
.OptionButton3.Value = False

<snip

With Worksheets("Sheet25")
.OptionButton1.Value = True
.OptionButton2.Value = False
.OptionButton3.Value = False
End With
With Worksheets("Sheet26")
.OptionButton1.Value = True
.OptionButton2.Value = False
.OptionButton3.Value = False
End With
Beep
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default slow macto

Application.enableevents doesn't apply to these optionbutton changes.

You have to do it yourself.

At the top of a General module (not in the ThisWorkbook and not behind a
worksheet), add this line:

Public BlkProc as boolean

Then in your code, toggle that variable:

Sub SetSwitch1()
Dim ws3 As Worksheet
Set ws3 = Worksheets("Sheet1")
ws3.Range("A2").Value = "Switch1"

BlkProc = true '<---- Added
With Worksheets("Sheet2")

.....
With Worksheets("Sheet26")
.OptionButton1.Value = True
.OptionButton2.Value = False
.OptionButton3.Value = False
End With
Beep

blkProc = false '<-- added
End Sub


Then in each of those OptionButton_click or change or whatever events, you have
to add a line to check that variable:

Private Sub OptionButton1_Change() '
If BlkProc = true then exit sub
rest of code here
End sub





Fan924 wrote:

When this macro listed only 10 sheets, it worked fine & ended with a
single beep. Now that I made it work on 25 sheets, it hangs up for 3
seconds and ends with 7 beeps. I added Application.EnableEvents at the
front and end and it did not help. All sheets have these button names.
Where did I go wrong? excel 97

Sub SetSwitch1()
Dim ws3 As Worksheet
Set ws3 = Worksheets("Sheet1")
ws3.Range("A2").Value = "Switch1"
With Worksheets("Sheet2")
.OptionButton1.Value = True
.OptionButton2.Value = False
.OptionButton3.Value = False
End With
With Worksheets("Sheet3")
.OptionButton1.Value = True
.OptionButton2.Value = False
.OptionButton3.Value = False
End With
With Worksheets("Sheet4")
.OptionButton1.Value = True
.OptionButton2.Value = False
.OptionButton3.Value = False

<snip

With Worksheets("Sheet25")
.OptionButton1.Value = True
.OptionButton2.Value = False
.OptionButton3.Value = False
End With
With Worksheets("Sheet26")
.OptionButton1.Value = True
.OptionButton2.Value = False
.OptionButton3.Value = False
End With
Beep
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default slow macto

Thank you Dave, worked great.
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
Slow Tab Tony7659 Excel Discussion (Misc queries) 0 August 5th 09 09:49 PM
VERY SLOW Yousoft Excel Discussion (Misc queries) 1 December 11th 07 12:56 PM
Slow Excel Navigation with Up / Down Arrow and slow scrolling deddog Excel Discussion (Misc queries) 0 August 14th 07 09:56 PM
Slow VBA, Can someone please look at it? Nic@Rolls-Royce[_5_] Excel Programming 1 February 5th 04 02:57 PM
Slow Down... James Rose[_3_] Excel Programming 3 December 24th 03 06:44 PM


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