Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Oct 2005
    Location
    Charleston, South Carolina, USA
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Find & Replace Function (MS Excel 03)

    I'm have problem trying to figure out the correct formula or code I need to use to solve the following problem.

    I have an excel sheet which contains 4 columns of data. In column A there is a list of IDs, column B is blank, Column C is another list of IDs, and column D is a list of headlines. I'm looking for a function to check to see if one of the IDs in in column A and also in column C. If true. copy the headline from column D which corresponds to the ID in column C and paste it in column B, next to the appropriate Id in column A. I hope that made since.
    One of the problem with this sheet is the some of the Cells in column A contain multiple ids separated by comas. I'm not sure how to tackle that problem
    I've attached the sheet for a little more clarification.

    Any help would be much appreciated.
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find & Replace Function (MS Excel 03)

    What do you want in column B if column A contains multiple IDs? A list of corresponding headlines, separated by commas?

  3. #3
    New Lounger
    Join Date
    Oct 2005
    Location
    Charleston, South Carolina, USA
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find & Replace Function (MS Excel 03)

    If possible I'd like the headline/s from column D pasted in column B and separated by a coma if there are multiple IDs in column A

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find & Replace Function (MS Excel 03)

    I don't think you can easily do this with a formula, but you can use the following macro:
    <code>
    Sub FillB()
    Dim r As Long
    Dim m As Long
    Dim n As Long
    Dim rngSearch As Range
    Dim arr As Variant
    Dim i As Integer
    Dim strPart As String
    Dim strHeadline As String
    m = Cells(Rows.Count, 1).End(xlUp).Row
    Range("B2:B" & m).ClearContents
    n = Cells(Rows.Count, 3).End(xlUp).Row
    Set rngSearch = Range("C2" & n)
    For r = 2 To m
    strHeadline = ""
    arr = Split(Cells(r, 1), ",")
    If UBound(arr) > -1 Then
    For i = LBound(arr) To UBound(arr)
    strPart = ""
    On Error Resume Next
    strPart = Application.WorksheetFunction.VLookup(arr(i), rngSearch, 2, False)
    On Error GoTo 0
    If Not strPart = "" Then
    strHeadline = strHeadline & "," & strPart
    End If
    Next i
    If Not strHeadline = "" Then
    Cells(r, 2) = Mid(strHeadline, 2)
    End If
    End If
    Next r
    End Sub</code>

  5. #5
    New Lounger
    Join Date
    Oct 2005
    Location
    Charleston, South Carolina, USA
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find & Replace Function (MS Excel 03)

    Thanks a lot Hans, This is exactly what I needed

    /r
    Sean

Posting Permissions

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