Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi all, I need help with inserting a variable number of columns. Heres the details: In one sheet I have 52 columns (this will always change) of data and in another I have 50 (again this will change). In the sheet with 50 I would like to insert X number of columns so both sheets have the same number. (52) I cannot just copy and paste as formulas I have written previously will be overwritten. I am fairly new to writing tihs type of code but heres what I have: Dim RawDataColCount As Integer Sheets("Raw Data").Select RawDataColCount = Cells.SpecialCells(xlCellTypeLastCell).Column Sheets("Data").Select Dim DataColCount As Integer DataColCount = Columns("B:AY").Count If RawDataColCount DataColCount Then Sheets("Data").Select Range("B:B").Select Selection.Insert Shift:=xlToRight Do Until DataColCount = RawDataColCount DataColCount = DataColCount + 1 Loop End If -- moglione1 ------------------------------------------------------------------------ moglione1's Profile: http://www.excelforum.com/member.php...o&userid=26414 View this thread: http://www.excelforum.com/showthread...hreadid=530422 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If RawDatacolcount Datacolcount Then
Range("B:B").Resize(, RawDatacolcount - Datacolcount).Select Selection.Insert Shift:=xlToRight End If This will insert n columns at a time HTH -- AP "moglione1" a écrit dans le message de ... Hi all, I need help with inserting a variable number of columns. Heres the details: In one sheet I have 52 columns (this will always change) of data and in another I have 50 (again this will change). In the sheet with 50 I would like to insert X number of columns so both sheets have the same number. (52) I cannot just copy and paste as formulas I have written previously will be overwritten. I am fairly new to writing tihs type of code but heres what I have: Dim RawDataColCount As Integer Sheets("Raw Data").Select RawDataColCount = Cells.SpecialCells(xlCellTypeLastCell).Column Sheets("Data").Select Dim DataColCount As Integer DataColCount = Columns("B:AY").Count If RawDataColCount DataColCount Then Sheets("Data").Select Range("B:B").Select Selection.Insert Shift:=xlToRight Do Until DataColCount = RawDataColCount DataColCount = DataColCount + 1 Loop End If -- moglione1 ------------------------------------------------------------------------ moglione1's Profile: http://www.excelforum.com/member.php...o&userid=26414 View this thread: http://www.excelforum.com/showthread...hreadid=530422 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Formula Help: When a Number is Reached | New Users to Excel | |||
Count number of cells until blank cell is reached | Excel Worksheet Functions | |||
unable to insert columns in excel, insert- columns (disabled) | Excel Discussion (Misc queries) | |||
Insert Next? Or insert a variable number of records...how? | Excel Discussion (Misc queries) | |||
Adding a certain number until minimum is reached | Excel Discussion (Misc queries) |