Option group

dasadler
5StarLounger
Posts: 889
Joined: 25 Jan 2010, 16:26
Location: Garden Grove, CA 92844 USA

Option group

Post by dasadler »

I have a worksheet with an option group of three radio buttons. They are linked to cell P3. I can select the radio buttons and the value of P3 will change to 1, 2, or 3. All works well.

Now, I would like to ask how can I have cell P3 (and the option group) display a value based on another cell? For example, I will enter a date in cell A1 and if that date is not in the Month of December OR in December but NOT Friday or Saturday, cell P3 and the option group should be 1. If that date is in December AND it is a Friday or Saturday, cell P3 and the option group should be 2. If that date is 12/31/XX, the value should be 3. If cell A1 does not have a date entered, then cell P3 and the option group should be 1.

I wanted to put a table in here recapping these conditions but I couldn't figure out how to do it so here is a table graphic.
You do not have the required permissions to view the files attached to this post.
Don

User avatar
HansV
Administrator
Posts: 78594
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Option group

Post by HansV »

Put the following formula in P3:

=IF(AND(MONTH(A1)=12,DAY(A1)=31),3,IF(AND(MONTH(A1)=12,WEEKDAY(A1)>5),2,1))

See the thread A Word macro for creating a table in a post for a way to create tables in a post.
Best wishes,
Hans

dasadler
5StarLounger
Posts: 889
Joined: 25 Jan 2010, 16:26
Location: Garden Grove, CA 92844 USA

Re: Option group

Post by dasadler »

Thank you Hans, that is great. I notice, though, that I can override (replace the contents of P3) if I actually select an option button. If I wanted to have a macro button to reset that formula, would it simply be?

Code: Select all

wsh.Range("P3").Value = "=IF(AND(MONTH(A1)=12,DAY(A1)=31),3,IF(AND(MONTH(A1)=12,WEEKDAY(A1)>5),2,1))"
Don

User avatar
HansV
Administrator
Posts: 78594
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Option group

Post by HansV »

Yep.
Best wishes,
Hans

dasadler
5StarLounger
Posts: 889
Joined: 25 Jan 2010, 16:26
Location: Garden Grove, CA 92844 USA

Re: Option group

Post by dasadler »

Cool
Don