VBA Control Button Selection

drefiek2

Board Regular
Joined
Apr 23, 2023
Messages
59
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hi,
I have a button with a code which saves a sheet as a PDF when clicked. I also have two option buttons (Option Button 20 and Option Button 21) on the same sheet. If one is toggled the other is not toggled and vice versa. What I would like to do is on the same 'Save as PDF' code I have already, insert some additional code to the existing save as pdf code which will do the following:

BEFORE the save PDF bit of code:
Toggle Option Button 20 ONLY IF Option Button 21 is already toggled.
Keep Option Button 20 toggled if it is toggled already.

AFTER the save PDF bit of code:
Toggle Option Button 21 again ONLY IF Option Button 21 was toggled beforehand.
Keep Option Button 20 toggled if it is toggled already.

I essentially only want the save PDF bit of code to run if Option Button 20 is selected. It should temporarily force Option Button 20 into selection during the code run in the event that Option Button 21 is selected beforehand.

I have tried so many codes I've found on Google but nothing works, I keep getting error 438 object does not support this property or method. Any help most appreciated. They are FORM CONTROL BUTTONS not ActiveX.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
To reference and get option button value for form controls try
MsgBox ActiveSheet.Shapes("Option button 20").ControlFormat.Value
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,432
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top