Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Excel radio button code

Posted on 2013-01-29
8
846 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
ID: 38833336
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 46

Expert Comment

by:Martin Liss
ID: 38833468
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
ID: 38835610
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 26

Expert Comment

by:redmondb
ID: 38835789
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
 

Author Comment

by:paulmcneil
ID: 38836179
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
ID: 38836503
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
ID: 38846075
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
ID: 38912173
Thanks, paulmcneil.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

856 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