+ Reply to Thread
Results 1 to 4 of 4

Need an indicator column - not using IF statement??

  1. #1
    Registered User
    Join Date
    02-23-2011
    Location
    Hampshire, England
    MS-Off Ver
    Excel 2007
    Posts
    71

    Question Need an indicator column - not using IF statement??

    Hello,

    Instead of doing a complicated nested IF statement I hope one of you genius's may provide a more elegant solution

    I have a column of school ID numbers and I want to create another column to specify one of the following

    Primary (starts with 2 or 3)
    Secondary (starts with a 4)
    Special (starts with a 7)
    PRU (starts with a 1)

    One of the schools is unique as it has both primary and secondary children. So all children who are Year 7 or above are secondary and all others are primary.

    Any ideas?

    Thanks

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Need an indicator column - not using IF statement??

    =LOOKUP(LEFT(A1,1),{1,2,3,4,7},{"PRU","Primary","Primary","Secondary","Special"})
    where A1 is the school number

    Also not sure why you dont want to use a nested IF as there are only five outcomes.

    Dunno about your unique school problem, you'd need to look at the age of the schoolchildren but you havent given any info on where that is in the spreadsheet.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    02-23-2011
    Location
    Hampshire, England
    MS-Off Ver
    Excel 2007
    Posts
    71

    Re: Need an indicator column - not using IF statement??

    Thanks, for some reason the LEFT function returned a text value even though the IDs are numerical.

    So I amended it to VALUE(LEFT(A2,1)) so that is fine.

    The age is in a separate column so I have created the following

    =IF(AND(A2=4505,B2>6),"Sec",IF(A2<>4505,LOOKUP(VALUE(LEFT(A2,1)),{1,2,3,4,7},{"PRU","Pri","Pri","Sec","Spe"}),"Pri"))

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Need an indicator column - not using IF statement??

    The IDs are not numerical - they are part of a text string. That's why you needed the VALUE function to convert them. The other way would be this:

    =IF(AND(A2=4505,B2>6),"Sec",IF(A2<>4505,LOOKUP(LEFT(A2,1),{"1","2","3","4","7"},{"PRU","Pri","Pri","Sec","Spe"}),"Pri"))
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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. select row and column only for the range indicator
    By max_max in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-12-2015, 04:01 AM
  2. How do I change the color of the indicator cell in row and column
    By Jim the Estimator in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-01-2013, 04:20 AM
  3. Inserting indicator column into spreadsheet
    By ThePrawn in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-29-2008, 08:27 AM
  4. Excel should have row column highlight indicator
    By ih1234 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-19-2006, 08:34 AM
  5. Replies: 6
    Last Post: 10-28-2005, 03:05 AM
  6. How do I change the color of the indicator cell in row and column
    By Damon Longworth in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-06-2005, 06:05 PM
  7. How do I change the color of the indicator cell in row and column
    By Jim the Estimator in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 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