0

I have an Order Sheet which includes a combination of check boxes and also option buttons.

  • There are 10 rows of 3 option buttons and 1 checkbox. Each row is grouped together.
  • The check boxes work fine and I am able to refer to them using a variable i which refers to the row number.
    • I have tried to do the same for the Option buttons. I.e I am trying to refer to the option buttons using variable i. However, I have been unable to find a solution.

This is the code I am using to refer to the check-boxes using variable i. This works fine.

    If Sheets("Order Sheet").Shapes("Check Box " & i).ControlFormat.Value = 1 Then

I have used a similar logic to try and refer to the option buttons. However, all variations of my trial and error based on vaguely similar things that I have found online have failed.

If OLEObjects("OptionButton" & i + 30).Object.Value = True Then

The current error with the code snippet above is "Sub or function not defined". Highlighting the OLEObjects line of code.

Any help or direction on where to go with including a variable in the naming of the option buttons would be greatly appreciated.

4
  • Did you try If Sheets("Order Sheet").Shapes("Option Button " & i).ControlFormat.Value = 1 Then ? Commented Mar 18, 2019 at 10:25
  • Are the shapes of those option buttons grouped? Commented Mar 18, 2019 at 10:26
  • Can you determine the exact name of the option buttons? If you click on them you should see their name next to the formula bar where you usually see the name of the active celll (e.g. A1). What is their name? Commented Mar 18, 2019 at 10:27
  • @z32a7ul this was already solved Commented Mar 18, 2019 at 10:28

1 Answer 1

2

You need to specify in which worksheet your OLEObjects is:

ThisWorkbook.Worksheets("Sheet1").OLEObjects  

Also see the documentation: OLEObjects object.

Sign up to request clarification or add additional context in comments.

1 Comment

That was easy! I had the line of code in a with statement, so I was just missing a dot preceding the OLEObjects. I'll have a look at the documentation also.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.