PDA

View Full Version : Adding Columns into Excel with a Macro



Decision
12-03-2014, 04:35 AM
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.

snb
12-03-2014, 05:15 AM
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

Decision
12-03-2014, 06:03 AM
Where do I need to insert this?

Decision
12-03-2014, 06:12 AM
Thanks! It works. You're a genius!

Decision
12-03-2014, 09:47 AM
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 X:DL, 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!

snb
12-03-2014, 10:24 AM
Did you read your PM ?