Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Insert a fixed number of lines between a varying range of cells

I am sent a continuous range of client IDs for a report every month that will
vary in length each month. In between each client ID I need to insert 6
empty rows. Does anyone know how this can be done through the use of a
macro? I don't know how to get excel to put 6 rows between each original
cell for the full range of data that will change each month. Any help would
be greatly appreciated
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Insert a fixed number of lines between a varying range of cells

Hi,

I've assumed these ID's are in columnA. Right click your sheet tab, view
code and paste this in and run it

Sub Prime_Lending()
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For x = lastrow To 2 Step -1
If Cells(x, 1).Value < Cells(x - 1, 1).Value Then
For i = 1 To 6
Rows(x).Insert Shift:=xlUp
Next
End If
Next
End Sub

Mike

"dschindler" wrote:

I am sent a continuous range of client IDs for a report every month that will
vary in length each month. In between each client ID I need to insert 6
empty rows. Does anyone know how this can be done through the use of a
macro? I don't know how to get excel to put 6 rows between each original
cell for the full range of data that will change each month. Any help would
be greatly appreciated

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Insert a fixed number of lines between a varying range of cells

Assuming a header row:

Sub lines()
Dim lr As Long, sh As Worksheet
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Set sh = ActiveSheet
For i = lr To 2 Step -1
Cells(i + 1, 1).Resize(6, 1).EntireRow.Insert
Next
End Sub




"dschindler" wrote:

I am sent a continuous range of client IDs for a report every month that will
vary in length each month. In between each client ID I need to insert 6
empty rows. Does anyone know how this can be done through the use of a
macro? I don't know how to get excel to put 6 rows between each original
cell for the full range of data that will change each month. Any help would
be greatly appreciated

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Insert a fixed number of lines between a varying range of cell

That's awesome, thanks!!!

"Mike H" wrote:

Hi,

I've assumed these ID's are in columnA. Right click your sheet tab, view
code and paste this in and run it

Sub Prime_Lending()
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For x = lastrow To 2 Step -1
If Cells(x, 1).Value < Cells(x - 1, 1).Value Then
For i = 1 To 6
Rows(x).Insert Shift:=xlUp
Next
End If
Next
End Sub

Mike

"dschindler" wrote:

I am sent a continuous range of client IDs for a report every month that will
vary in length each month. In between each client ID I need to insert 6
empty rows. Does anyone know how this can be done through the use of a
macro? I don't know how to get excel to put 6 rows between each original
cell for the full range of data that will change each month. Any help would
be greatly appreciated

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
How do I determine which data in a range add up to a fixed number? Mray Excel Worksheet Functions 5 May 27th 10 09:04 PM
How do I insert a decimal into a fixed number? Tom in Alaska Excel Discussion (Misc queries) 12 April 13th 10 11:48 PM
Insert a fixed number of characters clara Excel Programming 3 May 11th 07 01:10 PM
concatenate with a varying range of cells Riversage Excel Worksheet Functions 0 January 29th 07 07:43 PM
divide all numbers in range by a fixed number dhig3903 Excel Discussion (Misc queries) 2 August 9th 06 08:04 AM


All times are GMT +1. The time now is 10:06 PM.

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"