+ Reply to Thread
Results 1 to 4 of 4

Applying number formatting to a cell, dependent upon contents of another cell.

  1. #1
    Registered User
    Join Date
    03-01-2016
    Location
    Iowa
    MS-Off Ver
    2007
    Posts
    2

    Applying number formatting to a cell, dependent upon contents of another cell.

    I have a list of states in one column, and three types of licenses in the next three columns. Each type of license has a certain number format underneath it in the column.

    I need to either:
    1. Only allow entry of a number in a certain format, dependent upon the contents of 2 other cells.
    ie: if your state is Iowa, and your license is for a Pharmacist, your number would be only a 5 digit number.

    2. Highlight numbers in a column that do not match a certain format.
    ie: once everyone enters their license numbers, I can sort them by state, but after that, can I highlight cells that are NOT 5 digit numbers?
    Attached Files Attached Files

  2. #2
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,223

    Re: Applying number formatting to a cell, dependent upon contents of another cell.

    Dear IAPharmGirl : Plz refer attach file. Hope this you required.
    -------------------------------------------------------------------------------------------------------------------
    If you like the answer please say thanks by clicking the star in the bottom left hand corner of my post.
    And the forumn rules require you to edit your original post to mark as [SOLVED].
    Edit your original post in advanced edit and you should be good to go.

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

    Re: Applying number formatting to a cell, dependent upon contents of another cell.

    In your data entry, you will enter a state and a type of license and a license number. You want to look up based on the combination of state and type of license whether a number is the correct format. Is this correct?
    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.

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

    Re: Applying number formatting to a cell, dependent upon contents of another cell.

    Try the attached file.

    I am not sure I could prevent a bad data entry, but the following can be used to flag bad data as it is entered. You’ll need a couple of helper columns (these could be hidden).

    The key to this task is pattern matching. The attached picture shows some of the matches.

    For example to match a 5 digit number, use #####. To match the Pharmacist for Alaska, us PHAP####. To match anything use *.

    Some of the licenses could be a 4, 5, or 6 digit number. In this case, separate the patterns with commas like this: ####,#####,######.

    I did patterns for the first couple of states. I will leave it for you to do the rest. I think if there is no license like Maine, you may have to use *.

    There is one fancy formula in column D that does the lookup for the pattern: =VLOOKUP(A2,Table1,LOOKUP(B2,{"Intern","Pharmacist","Technician"},{6,5,7}),FALSE).

    The LOOKUP(B2,{"Intern","Pharmacist","Technician"},{6,5,7}) part finds the column position for the VLOOKUP based on the type of license seletected.

    Good luck with your project. If you get stuck on a pattern let me know.
    Attached Images Attached Images
    Attached Files Attached Files

+ 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: 4
    Last Post: 03-15-2011, 10:56 AM
  2. Cell validation dependent on contents of another cell
    By Berries in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-12-2010, 11:15 AM
  3. Make conditional formatting Macro dependent on cell number format
    By jbyrne in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2010, 10:26 AM
  4. Search dependent on cell contents
    By MisterPan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2008, 10:17 AM
  5. Replies: 1
    Last Post: 03-22-2006, 02:40 PM
  6. Another cell formatting dependent on cell contents question / message box popup?
    By StargateFan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-14-2006, 10:50 AM
  7. [SOLVED] Change Cell Color dependent on Cell Contents
    By Bill in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-15-2005, 01:06 PM

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