Consulting

Results 1 to 3 of 3

Thread: Question about concatenate

  1. #1
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location

    Question about concatenate

    FireFyter posted this code to a previous post:

    Dim start As Long, lastRow As Long 
    start = 4 
    lastRow = ExcelWS1.Range("A65536").End(xlUp).Row 
    Do 
        ExcelWS1.Range("F" & start).Value = _ 
        ExcelWS1.Range("G" & start).Value & ExcelWS1.Range("H" & start).Value & _ 
        ExcelWS1.Range("I" & start).Value & ExcelWS1.Range("J" & start).Value & _ 
        ExcelWS1.Range("K" & start).Value & ExcelWS1.Range("L" & start).Value 
        start = start + 1 
    Loop Until start > lastRow


    I was wondering how you would put a space or a hyphen between the merged data in column F.


    Last edited by Aussiebear; 04-29-2023 at 08:42 PM. Reason: Adjusted the code tags

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location

    found solution

    Sorry to take up space here. I looked at a formula I had for merging data in cells and figured out how to do it in the vba.

    this one will put a space


    Sub concateColA()
    Dim start As Long
        Dim lastRow As Long
        start = 4
        lastRow = [A65536].End(xlUp).Row
        Do
            Range("F" & start).Value = _
            Range("G" & start).Value & " " & Range("H" & start).Value & " " & _
            Range("I" & start).Value & " " & Range("J" & start).Value & " " & _
            Range("K" & start).Value & " " & Range("L" & start).Value
            start = start + 1
        Loop Until start > lastRow
    End Sub

    if you use this code in the line it will put a dash between the merged data:


    Range("G" & start).Value & "-" & Range("H" & start).Value & "-" & _
    Last edited by Aussiebear; 04-29-2023 at 08:43 PM. Reason: Adjusted the code tags

  3. #3
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    I was just about to post that until I saw you posted a solution! Got busy for a bit, but glad it was sorted!

Posting Permissions

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