Consulting

Results 1 to 6 of 6

Thread: Adding Columns into Excel with a Macro

  1. #1
    VBAX Regular
    Joined
    Nov 2014
    Posts
    10
    Location

    Adding Columns into Excel with a Macro

    I tried to add columns on every left side of a column with a number by using a macro.
    So next to the column with number 25 a new column, next to the column with number 40 and so on.. Untill number 12500.

    Attached Files Attached Files

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    In Book4

    Sub M_snb()
        sn = Split(Join(Application.Index(Sheet1.Cells(1).CurrentRegion.Rows(1).Value, 1, 0), "||"), "|")
        Sheet1.Cells(1).Resize(, UBound(sn) + 1) = sn
    End Sub

  3. #3
    VBAX Regular
    Joined
    Nov 2014
    Posts
    10
    Location
    Where do I need to insert this?

  4. #4
    VBAX Regular
    Joined
    Nov 2014
    Posts
    10
    Location
    Thanks! It works. You're a genius!

  5. #5
    VBAX Regular
    Joined
    Nov 2014
    Posts
    10
    Location
    Hi! I'm back again. I tried your code on an example workbook. Now I want to apply it to a specific table range. Can you maybe help me out again?

    The table is in the worksheet: 'Quotation Template (1)'
    The table starts in cell V32 and goes until DN299
    We want to insert a column to the left for every column in the range XL, just like before but then there are some extra columns to the left of the table.

    Hope to hear from you!! Would be great if you can be of help.

    Thanks in advance!

  6. #6
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    Did you read your PM ?

Posting Permissions

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