+ Reply to Thread
Results 1 to 4 of 4

Finding first instance of a value

  1. #1
    Registered User
    Join Date
    06-03-2011
    Location
    California
    MS-Off Ver
    Excel 2003
    Posts
    9

    Finding first instance of a value

    Is there an easy way to find if a value is the first instance in a set? For example...

    A
    A
    A
    B
    C
    C

    For value one I want to see if it is the first value in the range of all A's, if so do something otherwise do something else. Then for value 2 the same thing...
    Last edited by goldenclick; 06-06-2011 at 03:10 PM.

  2. #2
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Finding first instance of a value

    Hi,

    How about like this?

    Cheers,
    Attached Files Attached Files
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

  3. #3
    Registered User
    Join Date
    06-03-2011
    Location
    California
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Finding first instance of a value

    That works, thanks.

    =IF(COUNTIF($A$2:A11,A11)=1,"Do something","Do something else")

    Just to clarify, this says:

    If the count of A11 is 1 in the range A2:A11 then do something, otherwise do something else.

  4. #4
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    New England
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    554

    Re: Finding first instance of a value

    Correct, it's counting all values up until the current row. So if it's the first instance of it, the count will result in 1. With the If statement, if it is 1, you can "Do something", if it is not one, it is the repeat, you can "Do something else"

    You can use the formula =COUNTIF($A$2:A11,A11) to determine which it is (if you just want to see the 1/2 count rather than performing the next equation, just as a quick sanity check.
    Going for Guru! Click the Star to the bottom left of this post if I helped!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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