Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Combining the IF and List functions

Hi there, I'll try to explain my situation first

i have two cells next to each other

A1 | B1

Now A1 can either be "Yes" or "No"
If A1 is Yes, then B1 is automatically "N/A" - i can do this with a
simple IF statement.
BUT for B1 i want to use a drop down list of 4 options, so when A1 is
No then B1 can be any of the four options, BUT if A1 is No, then B1 is
automatically (and always) N/A


Please could someone help me do this...

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Combining the IF and List functions

If I understand what you want, you want the user to have a choice of 4
options in a drop-down list in B1 if A1 is No. If A1 is Yes, you want the
user to have no choice and B1 to be N/A.
You need VBA to do this. There is no way to combine an "IF" formula
with a drop-down (Data Validation) list.
This macro does what you want. Note that, as written, this macro requires
that your file have a sheet named "Utility". It is also required that A1:A4
of the Utility sheet contain the 4 items you want the user to choose from
when A1 of the active sheet is No and these 4 cells be named TheList. Also,
B1 of the Utility sheet must contain "N/A" without the quotes. Also, the
Data Validation in B1 must be "List" in the "Allow:" box and "=TheList"
(without the quotes) in the "Source:" box. This macro must be placed in the
sheet module of the sheet that contains the Yes/No in A1 and the drop-down
in B1. To access that module, right-click on the sheet tab, select View
Code, and paste this macro into that module.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target.Value = "" Then Exit Sub
If Target.Address(0, 0) = "A1" Then
Application.EnableEvents = False
With Sheets("Utility")
If Target.Value = "Yes" Then
.[B1].Name = "TheList"
[B1].Value = "N/A"
Else
.[A1:A4].Name = "TheList"
[B1].ClearContents
End If
End With
Application.EnableEvents = True
End If
End Sub
wrote in message
oups.com...
Hi there, I'll try to explain my situation first

i have two cells next to each other

A1 | B1

Now A1 can either be "Yes" or "No"
If A1 is Yes, then B1 is automatically "N/A" - i can do this with a
simple IF statement.
BUT for B1 i want to use a drop down list of 4 options, so when A1 is
No then B1 can be any of the four options, BUT if A1 is No, then B1 is
automatically (and always) N/A


Please could someone help me do this...



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
Combining AND and OR functions MZ New Users to Excel 1 December 21st 09 02:36 PM
combining functions Maggie Excel Discussion (Misc queries) 2 August 24th 09 11:44 PM
combining IF OR Functions kevan Excel Worksheet Functions 4 November 10th 08 02:14 AM
Combining Functions MikeM Excel Discussion (Misc queries) 3 September 30th 08 04:52 PM
Combining IF & AND functions Khoshravan Excel Discussion (Misc queries) 5 October 3rd 07 12:12 AM


All times are GMT +1. The time now is 01:21 PM.

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

About Us

"It's about Microsoft Excel"