Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 41
Default How to insert row automatically after certain number?

Hi,

I have a list that start from 1 to 2851 row, what I want to do is inserting
a blank row after 77 items. Each 77 items should be separated by row.

Thansk
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default How to insert row automatically after certain number?

Something like this should get you going:

Sub InsertNewRows()
Const firstRow = 1 ' change if needed
Const groupSize = 77 ' change if desired
'identify a column where there is
'something in a cell in it in the
'last used row on the sheet
Const baseColumn = "A"
Dim lastRow As Long

'for improved performance
Application.ScreenUpdating = False
'choose starting point
Range(baseColumn & groupSize + firstRow).Select
'initialize lastRow value
lastRow = Range(baseColumn & Rows.Count).End(xlUp).Row
'do the work
Do Until ActiveCell.Row lastRow
ActiveCell.EntireRow.Insert ' new row
ActiveCell.Offset(groupSize + 1, 0).Activate
'redefine last row
lastRow = Range(baseColumn & Rows.Count).End(xlUp).Row
Loop
End Sub

To put the code into your workbook press [Alt]+[F11] to open the VB Editor.
In there choose Insert | Module and copy and paste the code above into it.
Make any changes to baseColumn and firstRow that need to be made. Close the
VB Editor, choose the sheet with data on it and use Tools | Macro | Macros to
select the macro and [Run] it.


"ghost" wrote:

Hi,

I have a list that start from 1 to 2851 row, what I want to do is inserting
a blank row after 77 items. Each 77 items should be separated by row.

Thansk

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
automatically insert a row Rich Hayes Excel Worksheet Functions 4 March 17th 08 03:26 PM
automatically insert row Stephen Excel Discussion (Misc queries) 0 June 12th 06 02:29 PM
Insert Next? Or insert a variable number of records...how? Tom MacKay Excel Discussion (Misc queries) 0 April 20th 06 10:44 PM
Insert date automatically TUNGANA KURMA RAJU Excel Discussion (Misc queries) 1 September 29th 05 08:34 PM
Can you automatically insert next sequential number in an excel fo jo_9865 Excel Discussion (Misc queries) 2 August 4th 05 10:58 PM


All times are GMT +1. The time now is 08:43 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"