Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Inserting Lines

IS there a way to program Excel to insert a new line. For
example I need to have a new line instered every 23 lines
in a spreadsheet I am working on. Your help would be
greatly appreciated!

Christie

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Inserting Lines

Try this

Sub test()
Application.ScreenUpdating = False
Dim numRows As Integer
Dim R As Long
Dim Rng As Range
numRows = 1
Set Rng = ActiveSheet.UsedRange
For R = Rng.Rows.Count To 1 Step -23
Rng.Rows(R + 1).Resize(numRows).EntireRow.insert
Next R
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"C" wrote in message ...
IS there a way to program Excel to insert a new line. For
example I need to have a new line instered every 23 lines
in a spreadsheet I am working on. Your help would be
greatly appreciated!

Christie



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Inserting Lines

This will only work if your rows count is a multiple from 23
you can check that in the code also and make the range bigger ?

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Ron de Bruin" wrote in message ...
Try this

Sub test()
Application.ScreenUpdating = False
Dim numRows As Integer
Dim R As Long
Dim Rng As Range
numRows = 1
Set Rng = ActiveSheet.UsedRange
For R = Rng.Rows.Count To 1 Step -23
Rng.Rows(R + 1).Resize(numRows).EntireRow.insert
Next R
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"C" wrote in message ...
IS there a way to program Excel to insert a new line. For
example I need to have a new line instered every 23 lines
in a spreadsheet I am working on. Your help would be
greatly appreciated!

Christie





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Inserting Lines

Christie,

Enter the following macro in a code module (Alt+F11, Insert-Module):

'------
Option Explicit

Sub insertLines()
Dim startRow As Long, currRow As Long
Dim rowSpacing As Integer

startRow = 24 ' Enter first row to insert
rowSpacing = 23 ' Enter # of rows in each block

currRow = startRow

Do While True
If Application.Intersect(Rows(currRow), ActiveSheet.UsedRange) _
Is Nothing = True Then Exit Sub

ActiveSheet.Rows(currRow).Insert
currRow = currRow + rowSpacing + 1
Loop

End Sub
'------

HTH
Anders Silvén

"C" skrev i meddelandet
...
IS there a way to program Excel to insert a new line. For
example I need to have a new line instered every 23 lines
in a spreadsheet I am working on. Your help would be
greatly appreciated!

Christie



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
Copying and inserting lines teo410 Excel Worksheet Functions 6 August 13th 09 05:31 PM
inserting new lines with number tripflex Excel Discussion (Misc queries) 2 March 6th 09 10:10 PM
inserting lines throughout a spreadsheet Kerry Excel Worksheet Functions 3 October 18th 06 11:07 PM
Inserting # of lines from one spreadsheet to another klafert Excel Discussion (Misc queries) 1 August 30th 06 01:18 PM
Inserting Lines or Copying lines with formulas but without data wnfisba Excel Discussion (Misc queries) 2 August 18th 06 04:41 PM


All times are GMT +1. The time now is 09:09 AM.

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

About Us

"It's about Microsoft Excel"