Consulting

Results 1 to 4 of 4

Thread: VBA Concatenate based on another cell value

  1. #1

    VBA Concatenate based on another cell value

    Hi all,

    Please can you have a look at the spreadsheet i have attached. It has some example data and some more data of how i would want it to concatenate.

    i have placed the data in the columns that the real data is on, on my spreadsheet.

    Any help would be great.

    Regards
    Chris
    Attached Files Attached Files

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Sub ProcessData()
    Dim lastrow As Long
    Dim i As Long

    With ActiveSheet

    lastrow = .Cells(.Rows.Count, "D").End(xlUp).Row
    For i = lastrow To 3 Step -1

    If .Cells(i, "D").Value = .Cells(i - 1, "D").Value Then

    .Cells(i - 1, "E").Value = .Cells(i - 1, "E").Value & "," & _
    .Cells(i, "E").Value
    .Rows(i).Delete
    End If
    Next i
    End With
    End Sub
    [/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

  3. #3
    Thanks xld,

    How would you advise i learn VBA? Been trying for a few weeks but only bits seem to be sinking in.

    Reading doesnt seem to want to stay in my head haha

  4. #4
    VBAX Regular
    Joined
    Feb 2012
    Posts
    31
    Location
    Hi xld, I know there is some type of step through you can do on a code but does that actually tell you what each part does? Could you explain a little about the code you just did to help our learning please.
    ------------------------------------------------

    Thanks For All Your Help

    Windows 7

    Excel 2010

    Any codes I provide please try on a copy of your workbook first as these cannot be undone!

    To get the most precise answer, it is best to upload/attach a sample workbook (sensitive data scrubbed/removed/changed) that contains an example of your raw data on one worksheet, and on another worksheet your desired results.

    The structure and data types of the sample workbook must exactly duplicate the real workbook. Include a clear and explicit explanation of your requirements.

Posting Permissions

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