Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default Insert Blank Row Below Sub-Total?

Is there a more efficient way to insert a blank row after each sub-total line
other than to manually insert each one?
--
Miss Jenny
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,549
Default Insert Blank Row Below Sub-Total?


You can do it with only one insert command.
But you have to select a single cell in the row below each sub-total line.
Hold the Ctrl key down as you select each cell.
Then on the Insert menu choose 'Rows'.

Also, some VBA code could do it.
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Miss Jenny"

wrote in message
Is there a more efficient way to insert a blank row after each sub-total line
other than to manually insert each one?
--
Miss Jenny
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default Insert Blank Row Below Sub-Total?

I don't know how to write the VBA code. Do you?
--
Miss Jenny


"Jim Cone" wrote:


You can do it with only one insert command.
But you have to select a single cell in the row below each sub-total line.
Hold the Ctrl key down as you select each cell.
Then on the Insert menu choose 'Rows'.

Also, some VBA code could do it.
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Miss Jenny"

wrote in message
Is there a more efficient way to insert a blank row after each sub-total line
other than to manually insert each one?
--
Miss Jenny

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,549
Default Insert Blank Row Below Sub-Total?

Miss J,
Yes, I do. Sometimes the first version I write even works.
Select a column in the sub-totaled data and run the code below.
Each row in the selected column, that is blank, will have a row inserted above it.
You will not be able to undo the code or remove sub-totals after running the code.
Having a backup copy of the workbook or worksheet is advised.

'--Code starts here--
Sub AddRowsBelowSubtotal()
Dim rng As Range
Dim N As Long
Dim M As Long
Set rng = Selection.Columns(1)
If rng.Cells.Count = 1 Then
MsgBox "Select more than one cell. ", _
vbExclamation, "Blame Jim Cone"
Exit Sub
End If
Set rng = Application.Intersect(ActiveSheet.UsedRange, rng)
Set rng = rng.SpecialCells(xlCellTypeBlanks)
Application.ScreenUpdating = False
M = rng.Areas.Count
For N = M To 1 Step -1
rng.Areas(N).Rows(1).EntireRow.Insert shift:=xlDown
Next
Application.ScreenUpdating = True
MsgBox M & " rows were inserted. ", , "Blame Jim Cone"
Set rng = Nothing
End Sub
'-- Code ends here--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Miss Jenny"
wrote in message
I don't know how to write the VBA code. Do you?
--
Miss Jenny



"Jim Cone" wrote:
You can do it with only one insert command.
But you have to select a single cell in the row below each sub-total line.
Hold the Ctrl key down as you select each cell.
Then on the Insert menu choose 'Rows'.

Also, some VBA code could do it.
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Miss Jenny"

wrote in message
Is there a more efficient way to insert a blank row after each sub-total line
other than to manually insert each one?
--
Miss Jenny

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,836
Default Insert Blank Row Below Sub-Total?

This will do what you want:
http://excelusergroup.org/forums/t/538.aspx

I thought I knew hoe to do this, but I just realized that I don't. I
learned something new today. Thanks for asking this question Miss Jenny.


Regards,
Ryan---

--
RyGuy


"Jim Cone" wrote:

Miss J,
Yes, I do. Sometimes the first version I write even works.
Select a column in the sub-totaled data and run the code below.
Each row in the selected column, that is blank, will have a row inserted above it.
You will not be able to undo the code or remove sub-totals after running the code.
Having a backup copy of the workbook or worksheet is advised.

'--Code starts here--
Sub AddRowsBelowSubtotal()
Dim rng As Range
Dim N As Long
Dim M As Long
Set rng = Selection.Columns(1)
If rng.Cells.Count = 1 Then
MsgBox "Select more than one cell. ", _
vbExclamation, "Blame Jim Cone"
Exit Sub
End If
Set rng = Application.Intersect(ActiveSheet.UsedRange, rng)
Set rng = rng.SpecialCells(xlCellTypeBlanks)
Application.ScreenUpdating = False
M = rng.Areas.Count
For N = M To 1 Step -1
rng.Areas(N).Rows(1).EntireRow.Insert shift:=xlDown
Next
Application.ScreenUpdating = True
MsgBox M & " rows were inserted. ", , "Blame Jim Cone"
Set rng = Nothing
End Sub
'-- Code ends here--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Miss Jenny"
wrote in message
I don't know how to write the VBA code. Do you?
--
Miss Jenny



"Jim Cone" wrote:
You can do it with only one insert command.
But you have to select a single cell in the row below each sub-total line.
Hold the Ctrl key down as you select each cell.
Then on the Insert menu choose 'Rows'.

Also, some VBA code could do it.
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Miss Jenny"

wrote in message
Is there a more efficient way to insert a blank row after each sub-total line
other than to manually insert each one?
--
Miss Jenny




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default Insert Blank Row Below Sub-Total?

Thank you. The post from David B worked great!!!
--
Miss Jenny


"ryguy7272" wrote:

This will do what you want:
http://excelusergroup.org/forums/t/538.aspx

I thought I knew hoe to do this, but I just realized that I don't. I
learned something new today. Thanks for asking this question Miss Jenny.


Regards,
Ryan---

--
RyGuy


"Jim Cone" wrote:

Miss J,
Yes, I do. Sometimes the first version I write even works.
Select a column in the sub-totaled data and run the code below.
Each row in the selected column, that is blank, will have a row inserted above it.
You will not be able to undo the code or remove sub-totals after running the code.
Having a backup copy of the workbook or worksheet is advised.

'--Code starts here--
Sub AddRowsBelowSubtotal()
Dim rng As Range
Dim N As Long
Dim M As Long
Set rng = Selection.Columns(1)
If rng.Cells.Count = 1 Then
MsgBox "Select more than one cell. ", _
vbExclamation, "Blame Jim Cone"
Exit Sub
End If
Set rng = Application.Intersect(ActiveSheet.UsedRange, rng)
Set rng = rng.SpecialCells(xlCellTypeBlanks)
Application.ScreenUpdating = False
M = rng.Areas.Count
For N = M To 1 Step -1
rng.Areas(N).Rows(1).EntireRow.Insert shift:=xlDown
Next
Application.ScreenUpdating = True
MsgBox M & " rows were inserted. ", , "Blame Jim Cone"
Set rng = Nothing
End Sub
'-- Code ends here--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Miss Jenny"
wrote in message
I don't know how to write the VBA code. Do you?
--
Miss Jenny



"Jim Cone" wrote:
You can do it with only one insert command.
But you have to select a single cell in the row below each sub-total line.
Hold the Ctrl key down as you select each cell.
Then on the Insert menu choose 'Rows'.

Also, some VBA code could do it.
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Miss Jenny"

wrote in message
Is there a more efficient way to insert a blank row after each sub-total line
other than to manually insert each one?
--
Miss Jenny


  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,549
Default Insert Blank Row Below Sub-Total?


And this version inserts the row Below each blank cell in the column selected...
'--
Sub AddRowsBelowSubtotal_R1()
Dim rng As Range
Dim N As Long
Dim M As Long
Set rng = Selection.Columns(1)
If rng.Cells.Count = 1 Then
MsgBox "Select more than one cell. ", _
vbExclamation, "Blame Jim Cone"
Exit Sub
End If
Set rng = Application.Intersect(ActiveSheet.UsedRange, rng)
Set rng = rng.SpecialCells(xlCellTypeBlanks)
Application.ScreenUpdating = False
M = rng.Areas.Count
For N = M To 1 Step -1
With rng.Areas(N)
.Rows(.Rows.Count).Offset(1, 0).EntireRow.Insert shift:=xlDown
End With
Next
Application.ScreenUpdating = True
MsgBox M & " rows were inserted. ", , "Blame Jim Cone"
Set rng = Nothing
End Sub
'--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)
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
make cell show blank when total is zero Lindy Excel Discussion (Misc queries) 3 February 6th 08 03:09 PM
Total 12 columns starting with first non blank column BillyRogers Excel Worksheet Functions 9 September 27th 07 09:12 PM
How do I insert a Sub total at every page break? Sharon Excel Discussion (Misc queries) 1 February 20th 07 03:37 PM
make cell show blank when total is zero Bob L Excel Discussion (Misc queries) 3 May 19th 06 05:04 PM
Inserting Copied Row To Always Insert Above Sub Total Jamess Excel Worksheet Functions 0 November 9th 05 11:09 PM


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

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

About Us

"It's about Microsoft Excel"