![]() |
How to insert columns aftre each column of data
Hi All
I need to insert blank columns after each column of data on several worksheets. Can help? Thanks in advance. vcff |
How to insert columns aftre each column of data
Group the worksheets that should have this done to them.
Click on the first tab and ctrl-click on subsequent. Then run a macro: Option Explicit Sub testme() Dim wks As Worksheet Dim iCol As Long For Each wks In ActiveWindow.SelectedSheets With wks For iCol _ = .Cells.SpecialCells(xlCellTypeLastCell).Column To 1 Step -1 .Columns(iCol).Insert Next iCol End With Next wks End Sub If you're new to macros: Debra Dalgleish has some notes how to implement macros he http://www.contextures.com/xlvba01.html David McRitchie has an intro to macros: http://www.mvps.org/dmcritchie/excel/getstarted.htm Ron de Bruin's intro to macros: http://www.rondebruin.nl/code.htm (General, Regular and Standard modules all describe the same thing.) vcff wrote: Hi All I need to insert blank columns after each column of data on several worksheets. Can help? Thanks in advance. vcff -- Dave Peterson |
How to insert columns aftre each column of data
ps. remember to ungroup the sheets when you're done.
Rightclick on one of the selected sheets and choose Ungroup Sheets. vcff wrote: Hi All I need to insert blank columns after each column of data on several worksheets. Can help? Thanks in advance. vcff -- Dave Peterson |
How to insert columns aftre each column of data
Try this simple macro:
Sub column_adder() Application.ScreenUpdating = False Dim r As Range For i = Columns.Count To 2 Step -1 Set r = Columns(i) r.Select If Application.WorksheetFunction.CountA(r) 0 Then Selection.Insert Shift:=xlToRight End If Next Application.ScreenUpdating = True End Sub -- Gary''s Student - gsnu200794 "vcff" wrote: Hi All I need to insert blank columns after each column of data on several worksheets. Can help? Thanks in advance. vcff |
How to insert columns aftre each column of data
This macro would work.
Sub InsertCols() 'assume that a column has data if there is something in row 1 Range("IV1").End(xlToLeft).Select Let Y = ActiveCell.Column 'there are Y # of columns to insert For X = 1 To Y Columns(X + X).Select Selection.Insert Shift:=xlToRight Next End Sub |
How to insert columns aftre each column of data
Hi Gary
Thanks, it works and save me lot of time to insert col by col. "Gary''s Student" wrote: Try this simple macro: Sub column_adder() Application.ScreenUpdating = False Dim r As Range For i = Columns.Count To 2 Step -1 Set r = Columns(i) r.Select If Application.WorksheetFunction.CountA(r) 0 Then Selection.Insert Shift:=xlToRight End If Next Application.ScreenUpdating = True End Sub -- Gary''s Student - gsnu200794 "vcff" wrote: Hi All I need to insert blank columns after each column of data on several worksheets. Can help? Thanks in advance. vcff |
How to insert columns aftre each column of data
You are very welcome !
-- Gary''s Student - gsnu200794 "vcff" wrote: Hi Gary Thanks, it works and save me lot of time to insert col by col. "Gary''s Student" wrote: Try this simple macro: Sub column_adder() Application.ScreenUpdating = False Dim r As Range For i = Columns.Count To 2 Step -1 Set r = Columns(i) r.Select If Application.WorksheetFunction.CountA(r) 0 Then Selection.Insert Shift:=xlToRight End If Next Application.ScreenUpdating = True End Sub -- Gary''s Student - gsnu200794 "vcff" wrote: Hi All I need to insert blank columns after each column of data on several worksheets. Can help? Thanks in advance. vcff |
How to insert columns aftre each column of data
Hi Dave,
Thanks for the reminder. vcff "Dave Peterson" wrote: ps. remember to ungroup the sheets when you're done. Rightclick on one of the selected sheets and choose Ungroup Sheets. vcff wrote: Hi All I need to insert blank columns after each column of data on several worksheets. Can help? Thanks in advance. vcff -- Dave Peterson |
All times are GMT +1. The time now is 01:28 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com