Solved

Excel radio button code

Posted on 2013-01-29
8
831 Views
Last Modified: 2013-02-20
I have an Excel 97-2003 worksheet that has radio button controls. In design view, when I right click and pick Assign Macro, I see a macro named, for example, OptionButton8448_Click, but there is no way to edit the VBA code. The radio button does indeed causes cells to update, so there must be VBA code firing somewhere. My quesion is: how do I get a the VBA code behind the radio button? thanks!
0
Comment
Question by:paulmcneil
  • 5
  • 2
8 Comments
 
LVL 26

Expert Comment

by:redmondb
Comment Utility
Hi, paulmcneil.

A couple of things...
(1) While it can be linked to a macro, this kind of Option Button doesn't need one to effect changes.
(2) Your button doesn't have a macro. When you pick "Assign Macro", Excel proposes a macro name usually (?always?) based on the button's name - "OptionButton8448_Click",in your case.

how do I get a the VBA code behind the radio button?
Not the code, but to see what it's doing, right-click on it, pick "Format Control..." and click on the Control tab. You should see there the cell that's updated when the button is pressed/unpressed.

Regards,
Brian.
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
If I understand you correctly, to to "get at the VBA code" all you need to do is to go to the Macros menu, highlight the OptionButton8448_Click macro, and then click Edit.
0
 

Author Comment

by:paulmcneil
Comment Utility
Brian, you've got me headed there. I see the Cell link in the Control tab of the Format Control form for each radio button control. Another aspect of this is the radio button controls are grouped, so I can see a group box around the group of 7 radio buttons. This group of seven radio buttons are all linked to the same cell. When one button is clicked the value in the linked cell changes. How is the value that appears in the linked cell get assigned to each radio button in the group?
0
 
LVL 26

Expert Comment

by:redmondb
Comment Utility
paulmcneil,

It would make things clearer if you could delete any sensitive information and post the file here. (Alternatively paste the group box and buttons into a new file and post that.)

Thanks,
Brian.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:paulmcneil
Comment Utility
OK Brian. Attached is the workbbok. Click on any radio button in row 9, columns F-L and you'll see a vlue associated with the button display in cell W8 - Where does that value come from? Thanks
JobStandard.xlsx
0
 
LVL 26

Expert Comment

by:redmondb
Comment Utility
Thanks, paulmcneil.

The easy question is where it comes from - within a group the oldest button gets 1, the next 2 and so on.

I've been trying to find out where that information is held - so far without success, but I'm still on it!

Regards,
Brian.
0
 
LVL 26

Accepted Solution

by:
redmondb earned 500 total points
Comment Utility
paulmcneil,

Assuming xShape is a Shape variable set to an Option Button then...
xShape.OLEFormat.Object.Index
...is the value that will appear in the linked cell.

(A word of caution - this is from my own digging around rather than any documentation that I found.)

Regards,
Brian.
0
 
LVL 26

Expert Comment

by:redmondb
Comment Utility
Thanks, paulmcneil.
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

This very simple solution applies to a narrow cross-section of the "needs to close" variety. In this case, the full message in Event Viewer was in applog, Event ID 1000: Faulting application iexplore.exe, version 8.0.6001.18702, faulting module …
User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

772 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

11 Experts available now in Live!

Get 1:1 Help Now