+ Reply to Thread
Results 1 to 7 of 7

Conditional data types

  1. #1
    Registered User
    Join Date
    09-20-2018
    Location
    London, England
    MS-Off Ver
    15.26
    Posts
    6

    Conditional data types

    Hi,

    I'm currently stuck on a particular Excel problem, which essentially boils down to the following case: creating an Excel worksheet with the following features:
    - In cell A1, a drop-down list comprising of say "UK" and "USA"
    - In cell A2, a drop-down list "YES" and "NO" if A1 = UK and a blank cell (where a user could input a number) if A1 = USA

    I've looked into some Excel functions to address/circumvent the problem, such as IF, INDEX, MATCH but all of them work with the value datatype.
    I've also learnt how to create dependent drop-down lists based on other drop-down lists.

    However, from what I've tried/understood both these approaches fail to create cells that support conditional data types i.e where the data type of A2 varies according to the selection made in A1.

    I'd be glad to learn if there's a way to achieve that in Excel, with a preference for "basic" tools over more complex ones (i.e use of Excel functions vs VBA).

    Thank you to everyone taking the time to read/answer my post!

  2. #2
    Forum Contributor
    Join Date
    09-19-2018
    Location
    USA
    MS-Off Ver
    2016
    Posts
    208

    Re: Conditional data types

    Without using VBA, I don't think there's a way to do what you're asking.

    An option would be to use Data Validation like so:

    Select A1
    On Data tab, click Data Validation > Data Validation...
    Change 'Validation criteria' to List
    Beneath 'Source', type: UK,USA
    Leave 'Ignore blank' and 'In-cell dropdown' checked
    Click OK

    Select A2
    On Data tab, click Data Validation > Data Validation...
    Change 'Validation criteria' to List
    Beneath 'Source', type: Yes,No
    Leave 'Ignore blank' and 'In-cell dropdown' checked
    On 'Error Alert' tab, un-check box next to 'Show error alert after invalid data is entered'
    Click OK

    You can then select UK or USA in cell A1, then Yes or No in A2 - or enter any value you want into A2 since you turned off the invalid data warning.

    The drawback is that A2 will always have a drop-down showing Yes or No, even if you pick USA. It can be left blank, of course.

  3. #3
    Registered User
    Join Date
    09-20-2018
    Location
    London, England
    MS-Off Ver
    15.26
    Posts
    6

    Re: Conditional data types

    Thank you!

    I didn't know about the Error Alert tab.
    Guess I'll have to learn VBA then.
    I'll leave the thread open a little longer see if anyone else has something just in case.

  4. #4
    Forum Contributor
    Join Date
    09-19-2018
    Location
    USA
    MS-Off Ver
    2016
    Posts
    208

    Re: Conditional data types

    The following code, added to the worksheet module that has the data validation list in cell A1 (containing UK and USA), should allow you to control what appears in A2. In A1, if you select USA or leave it blank (or delete the current value) it clears cell A2 and would allow you to type anything. Once you select UK from the drop-down in A1, data validation is then added to A2 limited to Yes or No.
    Please Login or Register  to view this content.

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: Conditional data types

    Here is a little-two step using a named dynamic range.

    I happened to set up my range as D1:D2.

    In Formulas -> Name Manager I set up a name called "UK_List" with the Refers to: =IF(Sheet1!$A$1="UK",Sheet1!$D$1:$D$2,"")

    and I use a list validation =UK_List in Cell A2.

    Oddly enough it doesn't balk at all when you free form entry something in Cell A2.
    Attached Files Attached Files
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  6. #6
    Registered User
    Join Date
    09-20-2018
    Location
    London, England
    MS-Off Ver
    15.26
    Posts
    6

    Re: Conditional data types

    This is good but for A1= USA we still get a list, albeit an empty one.

    Thanks for telling me about dynamic ranges though.

  7. #7
    Registered User
    Join Date
    09-20-2018
    Location
    London, England
    MS-Off Ver
    15.26
    Posts
    6

    Re: Conditional data types

    This works just fine. Cheers!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 11
    Last Post: 08-13-2015, 08:12 AM
  2. Replies: 0
    Last Post: 07-28-2014, 05:49 PM
  3. I need a conditional Marco to search and open a different types of files!
    By brockmane in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-28-2012, 09:30 AM
  4. Replies: 0
    Last Post: 10-14-2010, 08:22 AM
  5. Conditional Formatting to highlight particular types of numbers?
    By pspounde in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-01-2007, 12:04 PM
  6. Data types?
    By Derek Norman in forum Excel General
    Replies: 2
    Last Post: 08-07-2005, 10:05 AM
  7. Data types - Help
    By Pastor Andrew Alexander in forum Excel General
    Replies: 1
    Last Post: 02-18-2005, 10:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1