Using Option buttons with vlookup

  • Thread starter Thread starter syndr
  • Start date Start date
S

syndr

I have a couple of vlookups in my spreadsheet and based on which option
(radio) button the user selects is the vlookup table it goes to.

Any sample code out there for this?
 
The value of an option button isn't directly accessible in a formula. However it can be made accessible to a formula by using the LinkedCell property of the option button which specifies a cell which will show its value.
I suggest that you use this property of the option button to show its value in a cell. Then test the value of that cell in your vlookup formula and do the vlookup accordingly.
Alternatively you could code a function which refers directly to the option button value, but it will be more long-winded.
HTH
 
I don't have sample code for this, but you might get more assistance if you
try someting and post the code for what you have.
 
I added a couple of optionbuttons from the forms toolbar and placed a groupbox
(from the forms toolbar) around them.

I assigned the linked cell to A1.

Then i built a couple of tables (b1:c2 and D1:E2) and added a value to lookup to
A2.

This formula worked ok for me:
=IF(A1=0,"",VLOOKUP(A2,IF(A1=1,$B$1:$C$2,$D$1:$E$2),2,FALSE))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top