Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Option button task

I'm not sure if this is possible or not, but I would like to use two option
buttons to determine the contents of a cell, which is dependent on the value
of another cell. As an example, if I insert 100 in cell A1, cell A2 would
display "Blue" if option button 1 is selected. However, if option button 2
is selected, then cell A2 would display "Red", (100 would still be in cell
A1). If I insert 200 in cell A1, then cell A2 would display "Purple" with
option button 1 selected or "Green" with option button 2 selected. Cell A2
would be able to return two different values of whatever was in cell A1,
depending on which option button was clicked. Any help with this would be
greatly appreciated. Thanks in advance.

D. Miller


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Option button task

1. On the worksheet, using the Forms toolbox set up 2 option buttons in
a frame and set the same Cell Link (here $D$2 but can use any) - which
automatically changes to 1 or 2 depending on the button clicked. Right
Click and assign the same macro to each button so it will run when it
is clicked. (alternatively could use the Change event or button to
run).


2. Conditional formatting is no use here, so we need a macro. Copy and
paste this :-

'------------------------------------------------
Sub test()
Dim FillColour As Integer
Blue = 8
Purple = 38
Red = 46
Green = 4
MyValue = ActiveSheet.Range("A1").Value
MyButton = ActiveSheet.Range("D1").Value
'---------------
If MyValue = 100 And MyButton = 1 Then
FillColour = Blue
ElseIf MyValue = 100 And MyButton = 2 Then
FillColour = Red
ElseIf MyValue = 200 And MyButton = 1 Then
FillColour = Purple
ElseIf MyValue = 200 And MyButton = 2 Then
FillColour = Green
Else
MsgBox ("Cannot resolve.")
Exit Sub
End If
ActiveSheet.Range("A2").Interior.ColorIndex _
= FillColour
End Sub
'--------------------------------------------------


3. For the *contents* of A2 you can either use a formula in the cell
using A1 and D1 or put the calculation in the macro.


---
Message posted from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Option button task

If you used option buttons from the Forms toolbar, you can link them to
a cell --
Right-click on the option button
Choose Format Control
Select the Control tab
Click in the Cell Link box, and then click on a worksheet cell,
e.g. $C$1

Set up a table with the values and options, e.g.

100 Blue Red
200 Purple Green

In cell A2, enter a formula that looks up the applicable value:

=VLOOKUP(A1,I2:K3,C1+1,0)

where the lookup table is in cell I2:K3

D. Miller wrote:
I'm not sure if this is possible or not, but I would like to use two option
buttons to determine the contents of a cell, which is dependent on the value
of another cell. As an example, if I insert 100 in cell A1, cell A2 would
display "Blue" if option button 1 is selected. However, if option button 2
is selected, then cell A2 would display "Red", (100 would still be in cell
A1). If I insert 200 in cell A1, then cell A2 would display "Purple" with
option button 1 selected or "Green" with option button 2 selected. Cell A2
would be able to return two different values of whatever was in cell A1,
depending on which option button was clicked. Any help with this would be
greatly appreciated. Thanks in advance.

D. Miller




--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Option button task

Thanks. Just what I was looking for.


"Debra Dalgleish" wrote in message
...
If you used option buttons from the Forms toolbar, you can link them to
a cell --
Right-click on the option button
Choose Format Control
Select the Control tab
Click in the Cell Link box, and then click on a worksheet cell,
e.g. $C$1

Set up a table with the values and options, e.g.

100 Blue Red
200 Purple Green

In cell A2, enter a formula that looks up the applicable value:

=VLOOKUP(A1,I2:K3,C1+1,0)

where the lookup table is in cell I2:K3

D. Miller wrote:
I'm not sure if this is possible or not, but I would like to use two

option
buttons to determine the contents of a cell, which is dependent on the

value
of another cell. As an example, if I insert 100 in cell A1, cell A2

would
display "Blue" if option button 1 is selected. However, if option button

2
is selected, then cell A2 would display "Red", (100 would still be in

cell
A1). If I insert 200 in cell A1, then cell A2 would display "Purple"

with
option button 1 selected or "Green" with option button 2 selected. Cell

A2
would be able to return two different values of whatever was in cell A1,
depending on which option button was clicked. Any help with this would

be
greatly appreciated. Thanks in advance.

D. Miller




--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
where will i get task pane option in Excel Guru Excel Discussion (Misc queries) 2 January 21st 08 03:38 PM
Option Button Pieter van der Walt Excel Worksheet Functions 2 March 27th 06 12:02 PM
keep source formatting is not an option in paste option button Tina Excel Discussion (Misc queries) 0 February 20th 06 09:58 PM
Option Button Help justaguyfromky Excel Worksheet Functions 2 September 5th 05 10:28 PM
Can I create a button in Excel that generates a task in Outlook? Tio777 Excel Discussion (Misc queries) 1 June 15th 05 03:41 PM


All times are GMT +1. The time now is 09:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"