1

I wonder why in my code in VBA option button doesn't work with variable (worksheet), but it works in the same macro when I use Me. or call it by full name ThisWorkbook.Worksheet("xxx"). etc.

My code:

Dim HBC As Worksheet
Set HBC = ThisWorkbook.Worksheets("HBCALC")
For i = 1 To 12
    If HBC.Metric = True Then
        If rng.Cells(1, i) = 0 Then Exit For
    End if
Next i

Metric is the option button name. When I use Me. or ThisWorkbook.Worksheets("HBCALC").Metric it works fine, but when I want to switch it to HBC.Metric it returns

Compile error: Method or data member not found.

GSerg
  • 76,472
  • 17
  • 159
  • 346

0 Answers0