Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,339
Default Control Toolbox and Private Sub Worksheet_Change(ByVal Target As R

Change event is initialised by data ENTRY: changing the cell via a formula
will not activate the code.

Try this:

I named A1 as "Toggle"

Private Sub ToggleButton1_Click()

Dim sh As Worksheet

For Each sh In Sheets(Array("Sheet2", "Sheet3"))
If Range("toggle") = 1 Then sh.Visible = xlSheetHidden
If Range("toggle") = 2 Then sh.Visible = xlSheetVisible
Next sh

End Sub

HTH

" wrote:

Control Toolbox and Private Sub Worksheet_Change(ByVal Target As Range)
-------------------------------------------------------------------------

Dear Everyone,

I really appreciate all help I can get.

Here goes:

1) I have a toggle button when its switched on, cell J2 shows TRUE. If it is
switched off then FALSE.

2) In cell A1, i have this formula: =IF(J2=TRUE,1,2)


3) I have this macro (which does not work with the toggle button).

'By Ron de Bruin
'If you enter 1 in A1 it hide sheet2 and sheet3
'If A1 = 2 it unhide them

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sh As Worksheet
If Not Application.Intersect(Range("A1"), Target) Is Nothing Then
For Each sh In Sheets(Array("Sheet2", "Sheet3"))
If Target.Value = 1 Then sh.Visible = xlSheetHidden
If Target.Value = 2 Then sh.Visible = xlSheetVisible
Next sh
End If
End Sub


Summary:
A1 = Determines hide or unhide (macro)
J2 = LinkedCell from toggle button

Note: If I enter value 1 or 2 in cell A1, the macro will work. But I wanna
use a toggle button or stuff from the control toolbox.



How can I get it to work.
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
Control Toolbox and Private Sub Worksheet_Change(ByVal Target Toppers Excel Discussion (Misc queries) 0 August 17th 07 01:52 AM
ByVal Target Range Great Code but need Help Mark Excel Discussion (Misc queries) 31 July 27th 07 03:11 PM
Private Sub Worksheet_Change(ByVal Target As Excel.Range) [email protected] Excel Worksheet Functions 0 December 21st 06 02:13 AM
Where is the control toolbox? Sol New Users to Excel 0 November 30th 06 02:20 PM
Where is the control toolbox? John New Users to Excel 0 November 30th 06 12:36 PM


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