Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I determine which data in a range add up to a fixed number? | Excel Worksheet Functions | |||
How do I insert a decimal into a fixed number? | Excel Discussion (Misc queries) | |||
Insert a fixed number of characters | Excel Programming | |||
concatenate with a varying range of cells | Excel Worksheet Functions | |||
divide all numbers in range by a fixed number | Excel Discussion (Misc queries) |