?
Solved

Excel radio button code

Posted on 2013-01-29
8
Medium Priority
?
866 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
[X]
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
  • 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 49

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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
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 2000 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
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 create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

719 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