Consulting

Results 1 to 9 of 9

Thread: Solved: All matched values in one Row

  1. #1
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location

    Solved: All matched values in one Row

    Hi,

    Need help..!

    Based on a certain criteria, I want all the corresponding cell values to appear in the same cell.

    Am attaching an example:
    Where ever the metric = 2, I want the value(from column A) returned in the same cell. Basically the correponding values should be concatendated and displayed in a single cell.

    So the output in the cell would be: a;d;e;f.

    Also, I have to do this without VBA.

    thanks a lot for the help,

    asingh

  2. #2
    VBAX Mentor MaximS's Avatar
    Joined
    Sep 2008
    Location
    Stoke-On-Trent
    Posts
    360
    Location
    I'm not sure if I got you right. Check attachement for details.

  3. #3
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location
    Hi,

    MaximS: Actually what I want, when ever there is an occurrence of a 2 in column B, I want the corresponding value from A returned. But all the Values from A should be concatendated in one cell.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    =IF(B2=2,A2&";","")&IF(B3=2,A3&";","")&IF(B4=2,A4&";","")&IF(B5=2,A5&";","" )&IF(B6=2,A6&";","")&IF(B7=2,A7&";","")&IF(B8=2,A8&";","")
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location
    Hi,

    XLD, thanks for the response, though I was trying this:

    =CONCATENATE(IF($B$2:$B$8=2,"Found;",""))

    As an array function. But it is not working....Was using the "Found;" to test for occurence, would this be a correct approach too..???

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It won't work, you cannot use CONCATENATE in an array, shame, but that is how it is.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location
    Okay,

    I guess I should have mentioned this before..so sorry, but my rows are going to be dynamic. So I need a method, where I do not have to right the formula as per the rows being evaluated, it will get too long.

    I would need to find the occurrence, and trap that "hit", and generate a value, and concatenate them ( as per the number of occurrences)..all in one cell....??

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Then you need VBA.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  9. #9
    VBAX Tutor david000's Avatar
    Joined
    Mar 2007
    Location
    Chicago
    Posts
    276
    Location
    [VBA]
    Sub aaa()
    Dim FoundCell, rCell As Range
    Dim d, strFirstAddress As String

    With Sheet1.Columns(2)
    Set rCell = .Find(2, lookat:=xlWhole, LookIn:=xlValues)
    strFirstAddress = rCell.Address
    Set FoundCell = rCell
    Do
    d = d & rCell.Offset(, -1) & ";"
    Set rCell = .FindNext(rCell)
    Set FoundCell = Union(FoundCell, rCell)
    Loop While Not rCell Is Nothing And rCell.Address <> strFirstAddress

    MsgBox Left(d, Len(d) - 1)
    End With
    End Sub

    [/VBA]

Posting Permissions

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