Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Inserting rows using a list of numbers

I have a spreadsheet with hundreds of rows and six columns (7 with total).
Once completed I need to insert a row for each column with data in. Each row
is a seperate project:e.g.
A B C D E
F Total
Project 1 £50 £100 £200 £400
£750

This row would need 4 blank rows inserting below the project number. I can
count the number of occupied cells, but cannot work out how to insert rows
using this info. Any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Inserting rows using a list of numbers

Hi,

The code below will insert 4 blank rows at every name change in column A.
Right click your sheet tab, view code and paste it in and run it.

Sub InsertRows()
MyColumn = "A"
For X = Cells(Rows.Count, MyColumn).End(xlUp).Row To 2 Step -1
If Cells(X - 1, MyColumn) < Cells(X, MyColumn) Then
Rows(X).Resize(4).Insert
End If
Next X
End Sub

Mike

"steverv" wrote:

I have a spreadsheet with hundreds of rows and six columns (7 with total).
Once completed I need to insert a row for each column with data in. Each row
is a seperate project:e.g.
A B C D E
F Total
Project 1 £50 £100 £200 £400
£750

This row would need 4 blank rows inserting below the project number. I can
count the number of occupied cells, but cannot work out how to insert rows
using this info. Any ideas?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Inserting rows using a list of numbers

Mike
I have a list of over 700 numbers that relate to the rows with data in them,
each of which is a project. Can this be used so the code picks up each number
and inserts rows based on these numbers? e.g.
Project Rows
No to Insert
Project 1 4
Project 2 2
Project 3 5
Project 4 2 etc..
Thanks
Steve

"Mike H" wrote:

Hi,

The code below will insert 4 blank rows at every name change in column A.
Right click your sheet tab, view code and paste it in and run it.

Sub InsertRows()
MyColumn = "A"
For X = Cells(Rows.Count, MyColumn).End(xlUp).Row To 2 Step -1
If Cells(X - 1, MyColumn) < Cells(X, MyColumn) Then
Rows(X).Resize(4).Insert
End If
Next X
End Sub

Mike

"steverv" wrote:

I have a spreadsheet with hundreds of rows and six columns (7 with total).
Once completed I need to insert a row for each column with data in. Each row
is a seperate project:e.g.
A B C D E
F Total
Project 1 £50 £100 £200 £400
£750

This row would need 4 blank rows inserting below the project number. I can
count the number of occupied cells, but cannot work out how to insert rows
using this info. Any ideas?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Inserting rows using a list of numbers

Hi,

This assumes you have a header row. It will take the number from the right
of the text string in column A and insert that many rows.

Sub InsertRows()
MyColumn = "A"
For X = Cells(Rows.Count, MyColumn).End(xlUp).Row To 2 Step -1
If Cells(X - 1, MyColumn) < Cells(X, MyColumn) Then
Rows(X).Offset(1).Resize(CLng(Mid(Cells(X, MyColumn), InStr(Cells(X,
MyColumn), " ") + 1))).Insert
Stop
End If
Next X
End Sub

Mike

"steverv" wrote:

Mike
I have a list of over 700 numbers that relate to the rows with data in them,
each of which is a project. Can this be used so the code picks up each number
and inserts rows based on these numbers? e.g.
Project Rows
No to Insert
Project 1 4
Project 2 2
Project 3 5
Project 4 2 etc..
Thanks
Steve

"Mike H" wrote:

Hi,

The code below will insert 4 blank rows at every name change in column A.
Right click your sheet tab, view code and paste it in and run it.

Sub InsertRows()
MyColumn = "A"
For X = Cells(Rows.Count, MyColumn).End(xlUp).Row To 2 Step -1
If Cells(X - 1, MyColumn) < Cells(X, MyColumn) Then
Rows(X).Resize(4).Insert
End If
Next X
End Sub

Mike

"steverv" wrote:

I have a spreadsheet with hundreds of rows and six columns (7 with total).
Once completed I need to insert a row for each column with data in. Each row
is a seperate project:e.g.
A B C D E
F Total
Project 1 £50 £100 £200 £400
£750

This row would need 4 blank rows inserting below the project number. I can
count the number of occupied cells, but cannot work out how to insert rows
using this info. Any ideas?

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 & Inserting Rows w/o Affecting other Rows Etc. LRay67 Excel Worksheet Functions 1 October 22nd 08 02:10 AM
lock a total row below a list & allow inserting in the list? Curious Consultant Excel Worksheet Functions 2 May 11th 07 04:14 PM
Inserting Blank rows after every row upto 2500 rows Manju Excel Worksheet Functions 8 August 22nd 06 12:54 PM
How to auto insert rows in a list of numbers zdek Excel Discussion (Misc queries) 3 June 16th 06 10:19 PM
Inserting rows eddie Excel Discussion (Misc queries) 1 October 18th 05 08:37 PM


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