Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Toggle button - procedure works but elegance needed (xl2007)

Hi,

I want to use the toggle button control to alternatively hide and unhide a
selection. My procedure works fine but I am using a linked cell to give a
True or False statement, that the procedure needs. Can the procedure respond
directly to the toggle button being pressed instead? Thx in advance.

the code:

Private Sub ToggleButton1_Click()
Dim SimSheet As Worksheet

Set SimSheet = ActiveSheet
With ActiveSheet
Set ToggleVal = Cells(35, 6)
If ToggleVal = True Then

ActiveSheet.Cells(37, 1).Select
Set tbl = ActiveCell.CurrentRegion
tbl.Resize(tbl.Rows.Count, tbl.Columns.Count).Select
Selection.EntireRow.Hidden = True

Else: Selection.EntireRow.Hidden = False

End If
End With
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,344
Default Toggle button - procedure works but elegance needed (xl2007)

Hi,

Yes,

Me.ToggleButton1.Value
or
Me.ToggleButton1
since Value is the default property.

This either returns False or True

If Me.ToggleButton1 = True then
'do something
Else
'do something else
End If

If this helps, please click the Yes button.

--
Thanks,
Shane Devenshire


"Kragelund" wrote:

Hi,

I want to use the toggle button control to alternatively hide and unhide a
selection. My procedure works fine but I am using a linked cell to give a
True or False statement, that the procedure needs. Can the procedure respond
directly to the toggle button being pressed instead? Thx in advance.

the code:

Private Sub ToggleButton1_Click()
Dim SimSheet As Worksheet

Set SimSheet = ActiveSheet
With ActiveSheet
Set ToggleVal = Cells(35, 6)
If ToggleVal = True Then

ActiveSheet.Cells(37, 1).Select
Set tbl = ActiveCell.CurrentRegion
tbl.Resize(tbl.Rows.Count, tbl.Columns.Count).Select
Selection.EntireRow.Hidden = True

Else: Selection.EntireRow.Hidden = False

End If
End With
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Toggle button - procedure works but elegance needed (xl2007)

Shane, thanks. I doesn't quite work though. I get the message: expected
procedure, not variable. What am I missing?


Private Sub ToggleButton1_Click()

Me.ToggleButton1
If Me.ToggleButton1 = True Then

ActiveSheet.Cells(37, 1).Select
Set tbl = ActiveCell.CurrentRegion
tbl.Resize(tbl.Rows.Count, tbl.Columns.Count).Select
Selection.EntireRow.Hidden = True

Else: Selection.EntireRow.Hidden = False

End If
End Sub

"ShaneDevenshire" wrote:

Hi,

Yes,

Me.ToggleButton1.Value
or
Me.ToggleButton1
since Value is the default property.

This either returns False or True

If Me.ToggleButton1 = True then
'do something
Else
'do something else
End If

If this helps, please click the Yes button.

--
Thanks,
Shane Devenshire


"Kragelund" wrote:

Hi,

I want to use the toggle button control to alternatively hide and unhide a
selection. My procedure works fine but I am using a linked cell to give a
True or False statement, that the procedure needs. Can the procedure respond
directly to the toggle button being pressed instead? Thx in advance.

the code:

Private Sub ToggleButton1_Click()
Dim SimSheet As Worksheet

Set SimSheet = ActiveSheet
With ActiveSheet
Set ToggleVal = Cells(35, 6)
If ToggleVal = True Then

ActiveSheet.Cells(37, 1).Select
Set tbl = ActiveCell.CurrentRegion
tbl.Resize(tbl.Rows.Count, tbl.Columns.Count).Select
Selection.EntireRow.Hidden = True

Else: Selection.EntireRow.Hidden = False

End If
End With
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Toggle button - procedure works but elegance needed (xl2007)

Your first code line: Me.ToggleButton1

Delete that line. It is meaningless in the context applied.





"Kragelund" wrote:

Shane, thanks. I doesn't quite work though. I get the message: expected
procedure, not variable. What am I missing?


Private Sub ToggleButton1_Click()

Me.ToggleButton1
If Me.ToggleButton1 = True Then

ActiveSheet.Cells(37, 1).Select
Set tbl = ActiveCell.CurrentRegion
tbl.Resize(tbl.Rows.Count, tbl.Columns.Count).Select
Selection.EntireRow.Hidden = True

Else: Selection.EntireRow.Hidden = False

End If
End Sub

"ShaneDevenshire" wrote:

Hi,

Yes,

Me.ToggleButton1.Value
or
Me.ToggleButton1
since Value is the default property.

This either returns False or True

If Me.ToggleButton1 = True then
'do something
Else
'do something else
End If

If this helps, please click the Yes button.

--
Thanks,
Shane Devenshire


"Kragelund" wrote:

Hi,

I want to use the toggle button control to alternatively hide and unhide a
selection. My procedure works fine but I am using a linked cell to give a
True or False statement, that the procedure needs. Can the procedure respond
directly to the toggle button being pressed instead? Thx in advance.

the code:

Private Sub ToggleButton1_Click()
Dim SimSheet As Worksheet

Set SimSheet = ActiveSheet
With ActiveSheet
Set ToggleVal = Cells(35, 6)
If ToggleVal = True Then

ActiveSheet.Cells(37, 1).Select
Set tbl = ActiveCell.CurrentRegion
tbl.Resize(tbl.Rows.Count, tbl.Columns.Count).Select
Selection.EntireRow.Hidden = True

Else: Selection.EntireRow.Hidden = False

End If
End With
End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Toggle button - procedure works but elegance needed (xl2007)

JLGWhiz, thanks, that did the trick.


"JLGWhiz" wrote:

Your first code line: Me.ToggleButton1

Delete that line. It is meaningless in the context applied.





"Kragelund" wrote:

Shane, thanks. I doesn't quite work though. I get the message: expected
procedure, not variable. What am I missing?


Private Sub ToggleButton1_Click()

Me.ToggleButton1
If Me.ToggleButton1 = True Then

ActiveSheet.Cells(37, 1).Select
Set tbl = ActiveCell.CurrentRegion
tbl.Resize(tbl.Rows.Count, tbl.Columns.Count).Select
Selection.EntireRow.Hidden = True

Else: Selection.EntireRow.Hidden = False

End If
End Sub

"ShaneDevenshire" wrote:

Hi,

Yes,

Me.ToggleButton1.Value
or
Me.ToggleButton1
since Value is the default property.

This either returns False or True

If Me.ToggleButton1 = True then
'do something
Else
'do something else
End If

If this helps, please click the Yes button.

--
Thanks,
Shane Devenshire


"Kragelund" wrote:

Hi,

I want to use the toggle button control to alternatively hide and unhide a
selection. My procedure works fine but I am using a linked cell to give a
True or False statement, that the procedure needs. Can the procedure respond
directly to the toggle button being pressed instead? Thx in advance.

the code:

Private Sub ToggleButton1_Click()
Dim SimSheet As Worksheet

Set SimSheet = ActiveSheet
With ActiveSheet
Set ToggleVal = Cells(35, 6)
If ToggleVal = True Then

ActiveSheet.Cells(37, 1).Select
Set tbl = ActiveCell.CurrentRegion
tbl.Resize(tbl.Rows.Count, tbl.Columns.Count).Select
Selection.EntireRow.Hidden = True

Else: Selection.EntireRow.Hidden = False

End If
End With
End Sub


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
addin menu button xl2007 [email protected] Excel Programming 2 July 31st 08 10:57 AM
Form button crashes XL2007 Dave Unger Excel Programming 0 October 26th 07 03:03 AM
UNIQ EXPEREINCE: PROCEDURE WORKS FINE USING F8 BUT GET ERROR WHEN COMMAND BUTTON IS CLICKED CAPTGNVR Excel Programming 1 July 6th 07 10:32 PM
Adding .xla button for Toggle Calculation Button Mike Excel Programming 5 August 19th 05 01:55 PM
defining an event procedure (lostfocus) that works on a column range juhlott Excel Programming 1 July 8th 04 08:26 PM


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