#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 390
Default Toggle Button oddity

I've constructed a simple toggle button to hide or unhide some
sheets. (I used a bit of the code contributed by Dave Peterson in
a related macro project I'm working on.) The button works fine.

But there's one oddity: if I click it twice, i.e., on and then
off, it then stops working until I click focus somewhere other
than the button. Then I can click on it again and it works for
another two times.

I can't figure out why. I have a very similar button that doesn't
stop working like that after two clicks. In fact, I copied the
first button to start out my coding for this one.

Any bright ideas?

--------------------------------------------
Private Sub ToggleButton2_Click()

Dim iCtr As Long
Dim wksNames As Variant
wksNames = Array("2006 Realized - CSV Data", _
"Current - CSV Data", "Symbol Lookup")

Application.ScreenUpdating = False

For iCtr = LBound(wksNames) To UBound(wksNames)
With Worksheets(wksNames(iCtr))
.Visible = ToggleButton2.Value
End With
Next iCtr

Application.ScreenUpdating = True
End Sub
--------------------------------------------

-dman-
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Toggle Button oddity

I couldn't reproduce the problem, either:

But maybe activating a cell will help:

Option Explicit
Private Sub ToggleButton2_Click()
Dim iCtr As Long
Dim wksNames As Variant

ActiveCell.Activate

'rest of code



Dallman Ross wrote:

I've constructed a simple toggle button to hide or unhide some
sheets. (I used a bit of the code contributed by Dave Peterson in
a related macro project I'm working on.) The button works fine.

But there's one oddity: if I click it twice, i.e., on and then
off, it then stops working until I click focus somewhere other
than the button. Then I can click on it again and it works for
another two times.

I can't figure out why. I have a very similar button that doesn't
stop working like that after two clicks. In fact, I copied the
first button to start out my coding for this one.

Any bright ideas?

--------------------------------------------
Private Sub ToggleButton2_Click()

Dim iCtr As Long
Dim wksNames As Variant
wksNames = Array("2006 Realized - CSV Data", _
"Current - CSV Data", "Symbol Lookup")

Application.ScreenUpdating = False

For iCtr = LBound(wksNames) To UBound(wksNames)
With Worksheets(wksNames(iCtr))
.Visible = ToggleButton2.Value
End With
Next iCtr

Application.ScreenUpdating = True
End Sub
--------------------------------------------

-dman-


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 390
Default Toggle Button oddity

In , Dave Peterson
spake thusly:

I couldn't reproduce the problem, either:

But maybe activating a cell will help:

Option Explicit
Private Sub ToggleButton2_Click()
Dim iCtr As Long
Dim wksNames As Variant

ActiveCell.Activate

'rest of code


That works!! Thanks ever so much, Dave.

-dman-

================================================== ======================
Dallman Ross wrote:

I've constructed a simple toggle button to hide or unhide some
sheets. (I used a bit of the code contributed by Dave Peterson in
a related macro project I'm working on.) The button works fine.

But there's one oddity: if I click it twice, i.e., on and then
off, it then stops working until I click focus somewhere other
than the button. Then I can click on it again and it works for
another two times.

I can't figure out why. I have a very similar button that doesn't
stop working like that after two clicks. In fact, I copied the
first button to start out my coding for this one.

Any bright ideas?

--------------------------------------------
Private Sub ToggleButton2_Click()

Dim iCtr As Long
Dim wksNames As Variant
wksNames = Array("2006 Realized - CSV Data", _
"Current - CSV Data", "Symbol Lookup")

Application.ScreenUpdating = False

For iCtr = LBound(wksNames) To UBound(wksNames)
With Worksheets(wksNames(iCtr))
.Visible = ToggleButton2.Value
End With
Next iCtr

Application.ScreenUpdating = True
End Sub
--------------------------------------------

-dman-


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
Auto Filter Toolbar Button Does not Toggle Pastel Hughes Excel Discussion (Misc queries) 2 October 26th 06 09:25 PM
Toggle Button NavEx Excel Worksheet Functions 1 May 23rd 06 02:40 AM
toggle button text color John Davies Excel Discussion (Misc queries) 5 December 12th 05 06:43 PM
Toggle button keithl816 Excel Discussion (Misc queries) 2 November 21st 05 09:16 PM
Toggle betwen "editing" and "pushing" a button in excel brjohnson9 Excel Discussion (Misc queries) 1 December 9th 04 12:02 AM


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