Consulting

Results 1 to 5 of 5

Thread: Create new column

  1. #1

    Question Create new column

    Hi Guys
    We have a series of columns,

    We want to create a new page that:
    Combining each column with other columns will create a new column, for example for column A, columns of AB, AC, AD, AE and AF should be created.
    For columns B, columns of BC, BD, BE and BF should be created.
    Finally, we need a code automatically creates these columns.
    EXCEL.jpg

  2. #2
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    Hi and welcome to the forum.

    Naming your columns A, B, C... is confusing eg Column A could contain "" Z Y X W... or 1 0 1 1...

    I'm guessing you want something like this

    VBAX67150.png

    Which can be done with this

    Sub test()
        Dim ar, i As Long, j As Long, k As Long
        ar = Range("B2:G8")
        k = 8
        For i = 1 To 5
            k = k + 1
            For j = 2 To 8
                Cells(j, k) = ar(j - 1, i) & ar(j - 1, i + 1)
            Next
        Next
    End Sub
    Format the destination cells as text.
    Semper in excretia sumus; solum profundum variat.

  3. #3
    Thanks a lot Paulked.
    I think I couldn't express my mean but fortunately I found the solution:
    Sub Blah()
    Set Source = Range("B1:G1")
    Set Destn = Range("H1")
    For g = 1 To 5
      For h = g + 1 To 6
            Destn.Value = Join(Array(Source.Cells(g), Source.Cells(h)), "")
            Set Destn = Destn.Offset(1)
      Next
    Next
    End Sub

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Looks like an adaptation of my code from somewhere!

  5. #5
    That's right.
    I changed it.

Posting Permissions

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