windsurferLA wrote:
I need to have numerous toggle buttons on a spread sheet. Rather than
have to replicate most of the macro code many times, I'd like to
substitute a variable for an object name in the lines of code.
'First I define ToggleBut as a string, and then I assign a value:
Dim ToggleBut as string
ToggleBut = "ToggleButton1"
'I then test the value of the object as shown in the next line, but
the test fails because my grammer is incorrect.
If ToggleBut.Value = False Then
'The code works when I use:
If ToggleButton1.Value = False Then
You can use
If Me.OLEObjects(ToggleBut).Object.Value = False Then
or you can use a class module to capture all of the toggle button click
events in one place. See
http://www.dicks-blog.com/archives/2...-events-class/
for more information on the latter.
--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com