ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Toggle Button help (https://www.excelbanter.com/excel-programming/382720-toggle-button-help.html)

jonco

Toggle Button help
 
I want to create 2 toggle buttons.

1.) Toggle button 1: When it is clicked cell C33 contains an "X" in it.
When it is clicked again the "X" goes away and the cell is empty.

2.) Toggle button 2: I want this toggle button to clear out certain cells
(a range) and when it is clicked again to put sample data in that range.

Sounds simple...but I'm having trouble figuring out how to do it.

Thanks for your help!

Jonco



Dave Peterson

Toggle Button help
 
I put two toggle buttons from the Control toolbox toolbar on a worksheet.

I put this in that worksheet's code module:


jonco wrote:

I want to create 2 toggle buttons.

1.) Toggle button 1: When it is clicked cell C33 contains an "X" in it.
When it is clicked again the "X" goes away and the cell is empty.

2.) Toggle button 2: I want this toggle button to clear out certain cells
(a range) and when it is clicked again to put sample data in that range.

Sounds simple...but I'm having trouble figuring out how to do it.

Thanks for your help!

Jonco


--

Dave Peterson

Dave Peterson

Toggle Button help
 
I put two toggle buttons from the Control toolbox toolbar on a worksheet.

I put this in that worksheet's code module:

Option Explicit
Private Sub ToggleButton1_Click()
If Me.ToggleButton1.Value = True Then
Me.Range("c33").ClearContents
Else
Me.Range("C33").Value = "X"
End If
End Sub

Private Sub ToggleButton2_Click()
Dim myRng As Range
Dim myArea As Range

Set myRng = Me.Range("a3:b9,c12:d18,f19,g1:h3")

If Me.ToggleButton2.Value = True Then
myRng.ClearContents
Else
For Each myArea In myRng.Areas
With myArea
.Formula = "=rand()"
.Value = .Value
End With
Next myArea
End If
End Sub


jonco wrote:

I want to create 2 toggle buttons.

1.) Toggle button 1: When it is clicked cell C33 contains an "X" in it.
When it is clicked again the "X" goes away and the cell is empty.

2.) Toggle button 2: I want this toggle button to clear out certain cells
(a range) and when it is clicked again to put sample data in that range.

Sounds simple...but I'm having trouble figuring out how to do it.

Thanks for your help!

Jonco


--

Dave Peterson

jonco

Toggle Button help
 
Thanks. I'll give that a try.

Jonco

"jonco" wrote in message
t...
I want to create 2 toggle buttons.

1.) Toggle button 1: When it is clicked cell C33 contains an "X" in it.
When it is clicked again the "X" goes away and the cell is empty.

2.) Toggle button 2: I want this toggle button to clear out certain
cells (a range) and when it is clicked again to put sample data in that
range.

Sounds simple...but I'm having trouble figuring out how to do it.

Thanks for your help!

Jonco





All times are GMT +1. The time now is 07:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com