Thread: Object problem
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default Object problem

If you have named your OptionButtons objOB1, objOB2, etc then you can use

For n = 1 To 12
If objOB & n = True Then month = n
Next


"Joao" wrote:

I have 12 optionbuttons and I am trying to run this code:
objOB1...objOB12

Private objOB As Object
...

Set objOB = OptionButton

For n = 1 To 12
If objOB(n).Value = True Then Month = n
Next n

but it gives me a Run-time error '91'
What I am doing wrong?