How do I set option button value using VBA

G

Guest

I have a option button control on my spread sheet and I want to be able to
set the value to either True or False using VBA code.

How do I refer to that object with in my Worksheet.

What I am trying to do is have VBA set will say OptButton1 to False upon the
workbook being closed.

Keep in mind the option button is an object in a worksheet Not a control on
a User Form.

Please Anyone , Help ?
Dan Thompson
 
G

Guest

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Sheets("Sheet1").OptionButton1 = False

End Sub
 
D

Dave Peterson

I wouldn't put it in the code before the workbook closes. The user can still
answer no to the save prompt (or you could save without asking and maybe damage
the workbook???).

I'd put the code in a procedure that runs when the workbook opens:

Option Explicit
Sub Auto_Open()
worksheets("sheet999").optionbutton1.value = false
end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top