Setting GroupName Property for OptionButtons in VBA Macro code

Posted on 2004-11-09
Last Modified: 2008-02-01
Dear Experts,

I currently am writing a macro in Excel to create a trio of Option Buttons which are located next to a cell which contains the name of one of my companies products.  The buttons will allow the user the opportunity to select a particular form of the product he wants. I have created this macro already for 30 products in a particular worksheet.  I went into each of the buttons and linked them to a certain cell (LinkedCell Property) and I gave each trio of buttons the same groupname (GroupName property).

Now I am doing a new version of the program which will cover 400 products.  I am trying to write a macro which will create the buttons, link them to a certain cell, and assign a group name to each trio.

Using a For Each loop and the Copy method, I have been able to create the trio of buttons.  The problem is that I am unable to assign a GroupName to each trio of buttons.  I get an 438 error that says Object doesn't support this Property or Method.

Can you show me what code I need to assign a GroupName and LinkedCell property to the new buttons I have created?


Question by:ydarg
    LVL 5

    Expert Comment

    The type of Option Button you are using is the VB style.  The Excel style doesn't have a GroupName (it relies on group boxes around the option buttons to show what goes with what)

    You access VB ones as follows ...

    ActiveSheet.OLEObjects("Test").Object.GroupName = "Test2"

    ActiveSheet.OLEObjects("Test").LinkedCell = "Sheet1!A1"

    Note the .Object in the Groupname one.
    LVL 5

    Accepted Solution

    "Test" was the name of my Option Button btw

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now