Initialising ToggleButtons

A

Alec Kolundzic

I am using the following code to initialise some
togglebuttons on opening a worksheet, but keep getting an
error message saying object required. What am I doing
wrong.

Thanks
Alec

Private Sub Workbook_Open()
With Worksheets("Sheet1")
ToggleButton1.Value = False
ToggleButton2.Value = True
ToggleButton3.Value = False
ToggleButton4.Value = True
ToggleButton5.Value = False
End With
End Sub
 
S

Stefan Hägglund [MSFT]

Hi Alec!

You have to add a dot before the ToggleButton rows, like:
Private Sub Workbook_Open()
With Worksheets("Sheet1")
..ToggleButton1.Value = False
..ToggleButton2.Value = True
..ToggleButton3.Value = False
..ToggleButton4.Value = True
..ToggleButton5.Value = False
End With
End Sub


Best regards

Stefan Hägglund
Microsoft
 
A

Alec Kolundzic

Thanks Stephan, that works a treat.
-----Original Message-----
Hi Alec!

You have to add a dot before the ToggleButton rows, like:
Private Sub Workbook_Open()
With Worksheets("Sheet1")
..ToggleButton1.Value = False
..ToggleButton2.Value = True
..ToggleButton3.Value = False
..ToggleButton4.Value = True
..ToggleButton5.Value = False
End With
End Sub


Best regards

Stefan Hägglund
Microsoft




.
 

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