ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Script for Radio Button (https://www.excelbanter.com/excel-programming/455040-vba-script-radio-button.html)

programmernovice[_2_]

VBA Script for Radio Button
 
My active sheet has 2 buttons labeled "High" and "Low". Selection of one deselects the other. Can someone please suggest a VBA script that would be equivalent to clicking on one of the buttons?

Many thanks for all help.

Claus Busch

VBA Script for Radio Button
 
Hi,

Am Wed, 27 Jan 2021 06:50:07 -0800 (PST) schrieb programmernovice:

My active sheet has 2 buttons labeled "High" and "Low". Selection of one deselects the other. Can someone please suggest a VBA script that would be equivalent to clicking on one of the buttons?


try:

Private Sub CommandButton1_Click()
With CommandButton1
If .Caption = "High" Then
'do the stuff you want for button "High"
.Caption = "Low"
Else
'do the stuff you want for button "Low"
.Caption = "High"
End If
End With
End Sub


Regards
Claus B.
--
Windows10
Office 2016

programmernovice[_2_]

VBA Script for Radio Button
 
On Wednesday, January 27, 2021 at 10:41:36 AM UTC-6, Claus Busch wrote:
Hi,
Am Wed, 27 Jan 2021 06:50:07 -0800 (PST) schrieb programmernovice:

My active sheet has 2 buttons labeled "High" and "Low". Selection of one deselects the other. Can someone please suggest a VBA script that would be equivalent to clicking on one of the buttons?

try:

Private Sub CommandButton1_Click()
With CommandButton1
If .Caption = "High" Then
'do the stuff you want for button "High"
.Caption = "Low"
Else
'do the stuff you want for button "Low"
.Caption = "High"
End If
End With
End Sub


Regards
Claus B.
--
Windows10
Office 2016

Greatly appreciate your help, Claus!

programmernovice[_2_]

VBA Script for Radio Button
 
On Wednesday, January 27, 2021 at 10:41:36 AM UTC-6, Claus Busch wrote:
Hi,
Am Wed, 27 Jan 2021 06:50:07 -0800 (PST) schrieb programmernovice:

My active sheet has 2 buttons labeled "High" and "Low". Selection of one deselects the other. Can someone please suggest a VBA script that would be equivalent to clicking on one of the buttons?

try:

Private Sub CommandButton1_Click()
With CommandButton1
If .Caption = "High" Then
'do the stuff you want for button "High"
.Caption = "Low"
Else
'do the stuff you want for button "Low"
.Caption = "High"
End If
End With
End Sub



Hello again Claus. It appears that the labels "high" and "low" are perhaps not the appropriate names for the radio buttons as needed by the script. I get

Run-time error '424'
Object required

Any suggestions? Thanks again for your guidance.




All times are GMT +1. The time now is 03:22 PM.

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