Inserting Columns

CARBOB

Well-known Member
Joined
Jun 6, 2005
Messages
1,870
I have in columns H:IY a 5-digit value. I would like to insert between each column a heading SKIP, so it wolud look like the bottom image. Is there an easy way to do this, or am I stuck with entering each column separate?
Excel Workbook
HIJ
10,2,4,5,70,4,5,6,72,3,4,7,8
Sheet1
Excel 2007
Excel Workbook
HIJK
10,2,4,5,7SKIP0,4,5,6,7SKIP
5 DIGIT PAIRS
Excel 2007
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
How about this:
Code:
Sub InsertWord()
    Dim LC As Long
    LC = Range("H1").End(xlToRight).Column
    Application.ScreenUpdating = False
    Columns("I:I").Insert Shift:=xlToRight
    Application.Goto Reference:=ActiveSheet.Range("I1")
    ActiveCell.Value = "SKIP"
    For i = 9 To LC
        ActiveCell.Copy
        ActiveCell.Offset(0, 2).Select
        Selection.Insert Shift:=xlToRight
    Next i
    Application.CutCopyMode = False
End Sub

It does what you asked for but it will place "SKIP" as the last entry in SQ1
 
Upvote 0
How's this:

<font face=Calibri><SPAN style="color:#00007F">Sub</SPAN> foo()<br>    <SPAN style="color:#00007F">Dim</SPAN> i <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>        <SPAN style="color:#00007F">For</SPAN> i = Cells(1, "IY").Column <SPAN style="color:#00007F">To</SPAN> Cells(1, "H").Column <SPAN style="color:#00007F">Step</SPAN> -1<br>            <SPAN style="color:#00007F">With</SPAN> Cells(1, i)<br>                .EntireColumn.Insert<br>                .Offset(, 1).Value = "SKIP"<br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>        <SPAN style="color:#00007F">Next</SPAN> i<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

HTH,
 
Upvote 0
Works like a charm, less than 30 seconds!!!! Very much appreciated, thank you!!



How's this:

<font face=Calibri><SPAN style="color:#00007F">Sub</SPAN> foo()<br>****<SPAN style="color:#00007F">Dim</SPAN> i <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>********<SPAN style="color:#00007F">For</SPAN> i = Cells(1, "IY").Column <SPAN style="color:#00007F">To</SPAN> Cells(1, "H").Column <SPAN style="color:#00007F">Step</SPAN> -1<br>************<SPAN style="color:#00007F">With</SPAN> Cells(1, i)<br>****************.EntireColumn.Insert<br>****************.Offset(, 1).Value = "SKIP"<br>************<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>********<SPAN style="color:#00007F">Next</SPAN> i<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

HTH,
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,183
Members
452,893
Latest member
denay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top