Home

Inserting New Columns of Empty Space between Pre-existing Columns

%3CLINGO-SUB%20id%3D%22lingo-sub-734847%22%20slang%3D%22en-US%22%3EInserting%20New%20Columns%20of%20Empty%20Space%20between%20Pre-existing%20Columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-734847%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20an%20excel%20spreadsheet%20with%20about%2050%20columns%20and%20I%20want%20to%20insert%20new%20columns%20of%20empty%20space%20around%20every%205%20columns%20(5th%2C%2010th%2C%2015th...).%20How%20would%20I%20go%20about%20doing%20that%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-734847%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Ee%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-735577%22%20slang%3D%22en-US%22%3ERe%3A%20Inserting%20New%20Columns%20of%20Empty%20Space%20between%20Pre-existing%20Columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-735577%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F370072%22%20target%3D%22_blank%22%3E%40dta255%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3Eyou%20can%20do%20it%20with%20the%20follwing%20macro%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3ESub%20InsertColumns()%3CBR%20%2F%3EDim%20lngCol%20As%20Long%3CBR%20%2F%3EDim%20lngColMax%20As%20Long%3CBR%20%2F%3E%3CBR%20%2F%3EWith%20ActiveSheet%3CBR%20%2F%3ElngColMax%20%3D%2051%3CBR%20%2F%3E%3CBR%20%2F%3EFor%20lngCol%20%3D%20lngColMax%20To%201%20Step%20-5%3CBR%20%2F%3E%3CBR%20%2F%3E.Columns(lngCol).Insert%3CBR%20%2F%3E%3CBR%20%2F%3ENext%20lngCol%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FPRE%3E%3CP%3EBest%20regards%20Bernd%3C%2FP%3E%3CP%3E%3CA%20title%3D%22VBA-Tanker%22%20href%3D%22https%3A%2F%2Fvba-tanker.com%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethe%20vba-tanker%20-%20a%20database%20full%20of%20macros%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
dta255
Occasional Visitor

Hello,

 

I have an excel spreadsheet with about 50 columns and I want to insert new columns of empty space around every 5 columns (5th, 10th, 15th...). How would I go about doing that?

 

 

1 Reply

@dta255 

Hi,

you can do it with the follwing macro:

 

Sub InsertColumns()
Dim lngCol As Long
Dim lngColMax As Long

With ActiveSheet
lngColMax = 51

For lngCol = lngColMax To 1 Step -5

.Columns(lngCol).Insert

Next lngCol

End With

End Sub

Best regards Bernd

the vba-tanker - a database full of macros