+ Reply to Thread
Results 1 to 6 of 6

Compare two Cells, Output somthing from a cell in the same row.

  1. #1
    Registered User
    Join Date
    04-30-2008
    Posts
    6

    Compare two Cells, Output somthing from a cell in the same row.

    Hi all, here is a copy of an example spreadsheet layout.

    #...Name..Status Code
    043 Brute Active Blue
    044 Brute Active Green
    ..... Kevan Closed Blue
    045 Brute Opened Blue
    046 Jacky Active Blue
    047 ...... Disabled

    Basicly what I want to do is iterate down the list row by row.

    I want to see if column two equals "Brute" and column three equals "Active".

    If it both match than output the contents of column 1 into lets say column 5 row 2.

    Any help would be greatly appreciated.
    Last edited by VBA Noob; 05-07-2008 at 02:47 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    You can use Index/Match

    e.g.
    Please Login or Register  to view this content.
    adjust ranges to suit and then confirmed with CTRL+SHIFT+ENTER not just ENTER.. you will see { } brackets appear around the formula
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    04-30-2008
    Posts
    6
    That works, but it only gets back one instanse of the match. I need it to return all the values that match that criteria. So if two match there would be a result of something like '043 044'. Any ideas?

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Try

    Please Login or Register  to view this content.
    Confirmed with CTRL+SHIFT+ENTER and copied down.

  5. #5
    Forum Contributor
    Join Date
    04-24-2007
    Location
    NYC
    MS-Off Ver
    2k3/2k7/2010
    Posts
    270
    Assuming that # is in Range("A1")

    Then you can make a macro that does the check for you.

    Sub match_Brute_active()
    Dim i as int
    i = 1
    do while Activesheet.Cells(i,1).value <>""
    if Activesheet.Cells(i, 2).value = "Brute" And Activesheet.Cells(i,3).value = "Active" then ' it's case sensitive
    Activesheet.Cells(i,5).value = 1
    endif
    i = i +1
    loop

    end sub

  6. #6
    Registered User
    Join Date
    04-30-2008
    Posts
    6
    I tweaked the code and it works perfectly. Much appreciated. THANKS AGAIN!!!!!

+ 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