Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Insert columns until a certain number has been reached


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Insert columns until a certain number has been reached

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula Help: When a Number is Reached morri3sa New Users to Excel 2 November 9th 10 11:34 PM
Count number of cells until blank cell is reached Patrick Hourigan Excel Worksheet Functions 1 August 4th 10 04:00 PM
unable to insert columns in excel, insert- columns (disabled) iam_leearner Excel Discussion (Misc queries) 1 August 13th 06 02:26 PM
Insert Next? Or insert a variable number of records...how? Tom MacKay Excel Discussion (Misc queries) 0 April 20th 06 10:44 PM
Adding a certain number until minimum is reached dk Excel Discussion (Misc queries) 3 December 7th 05 01:29 AM


All times are GMT +1. The time now is 05:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"