Using a variable to represent a Checkbox Name(OLEObject)

  • Thread starter Thread starter Mike Cooper
  • Start date Start date
M

Mike Cooper

Hi,

I would have thought this would be a simple matter

My VBA code includes the following code

ActiveSheet.Check_Box.Value = Range(Boolean_Identifier).Value

....where Check_Box is a variable containing the name of the checkbox I
want to
reference. This code is in a "For" loop and "Check_Box" gets
populated with the names of over 200 checkboxes that I want to process
in turn. Unfortunately the above line contantly errors on a "Type
mismatch". If I substitute the actual name of one of the check boxes
into the above line it works perfectly; though naturally, only for
that particular check box.

Obviously I am not defining or using my Check_Box variable properly.
I have tried multiple definitions based on tips I've found here in the
newsgroups to no effect. Can anyone please tell me how to properly
reference the name of Checkbox as a variable?

thank you,
Mike Cooper
 
Mike,

Try this

Activesheet.OLEObjects(Check_Box").Object.Value =
Range(Boolean_Identifier).Value
 
Back
Top