Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 17
Default how can I insert a blank row after each subtotal in a worksheet

I imported data, sorted and subtotalled the data by customer. Is there a way
I can insert a blank row after each subtotal, for readability when I print it
as a report?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default how can I insert a blank row after each subtotal in a worksheet

How can you identify a subtotal row? Does it contain a SUBTOTAL() function in
some column?
--
Gary''s Student - gsnu200828


"chappy" wrote:

I imported data, sorted and subtotalled the data by customer. Is there a way
I can insert a blank row after each subtotal, for readability when I print it
as a report?

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 17
Default how can I insert a blank row after each subtotal in a workshee

It does contain the word subtotal in column A.
Chappy

"Gary''s Student" wrote:

How can you identify a subtotal row? Does it contain a SUBTOTAL() function in
some column?
--
Gary''s Student - gsnu200828


"chappy" wrote:

I imported data, sorted and subtotalled the data by customer. Is there a way
I can insert a blank row after each subtotal, for readability when I print it
as a report?

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default how can I insert a blank row after each subtotal in a workshee

Here is a small macro. It scans down column A, looking for the word "subtotal"

When it finds the word, it inserts a blank row just below:

Sub lineAdd()
n = Cells(Rows.Count, 1).End(xlUp).Row
Dim radd As Range
Set radd = Nothing
For i = 1 To n
v = Cells(i, 1).Value
If InStr(UCase(v), "SUBTOTAL") < 0 Then
If radd Is Nothing Then
Set radd = Cells(i, 1)
Else
Set radd = Union(radd, Cells(i, 1))
End If
End If
Next
radd.Offset(1, 0).EntireRow.Insert
End Sub



Macros are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To use the macro from the normal Excel window:

1. ALT-F8
2. Select the macro
3. Touch Run



To remove the macro:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

--
Gary''s Student - gsnu200828


"chappy" wrote:

It does contain the word subtotal in column A.
Chappy

"Gary''s Student" wrote:

How can you identify a subtotal row? Does it contain a SUBTOTAL() function in
some column?
--
Gary''s Student - gsnu200828


"chappy" wrote:

I imported data, sorted and subtotalled the data by customer. Is there a way
I can insert a blank row after each subtotal, for readability when I print it
as a report?

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 17
Default macro looks good, thanks

Thanks a ton. I am very interested in what macros can do and will be
pursuing their use. I would have never figured this out. Really appreciated
it.

Chappy


  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 17
Default how can I insert a blank row after each subtotal in a workshee

Hi Gary's Student:
When I run the macro, it gives the following error and appears to be talking
about the next to the last line

Object variable or With block variable not set

Could use your help, again.

Chappy

"Gary''s Student" wrote:

Here is a small macro. It scans down column A, looking for the word "subtotal"

When it finds the word, it inserts a blank row just below:

Sub lineAdd()
n = Cells(Rows.Count, 1).End(xlUp).Row
Dim radd As Range
Set radd = Nothing
For i = 1 To n
v = Cells(i, 1).Value
If InStr(UCase(v), "SUBTOTAL") < 0 Then
If radd Is Nothing Then
Set radd = Cells(i, 1)
Else
Set radd = Union(radd, Cells(i, 1))
End If
End If
Next
radd.Offset(1, 0).EntireRow.Insert
End Sub



Macros are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To use the macro from the normal Excel window:

1. ALT-F8
2. Select the macro
3. Touch Run



To remove the macro:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

--
Gary''s Student - gsnu200828


"chappy" wrote:

It does contain the word subtotal in column A.
Chappy

"Gary''s Student" wrote:

How can you identify a subtotal row? Does it contain a SUBTOTAL() function in
some column?
--
Gary''s Student - gsnu200828


"chappy" wrote:

I imported data, sorted and subtotalled the data by customer. Is there a way
I can insert a blank row after each subtotal, for readability when I print it
as a report?

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default how can I insert a blank row after each subtotal in a workshee

It is failing. It can't find any rows in which the column A cell has the
text "Subtotal" or "subtotal" in them. For example if cell A10 has the text:

This is a subtotal

then a blank row would be inserted below. If subtotal appears as a function
rather than as text we will make a small change to the macro.


Let me know.
--
Gary''s Student - gsnu200828


"Chappy" wrote:

Hi Gary's Student:
When I run the macro, it gives the following error and appears to be talking
about the next to the last line

Object variable or With block variable not set

Could use your help, again.

Chappy

"Gary''s Student" wrote:

Here is a small macro. It scans down column A, looking for the word "subtotal"

When it finds the word, it inserts a blank row just below:

Sub lineAdd()
n = Cells(Rows.Count, 1).End(xlUp).Row
Dim radd As Range
Set radd = Nothing
For i = 1 To n
v = Cells(i, 1).Value
If InStr(UCase(v), "SUBTOTAL") < 0 Then
If radd Is Nothing Then
Set radd = Cells(i, 1)
Else
Set radd = Union(radd, Cells(i, 1))
End If
End If
Next
radd.Offset(1, 0).EntireRow.Insert
End Sub



Macros are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To use the macro from the normal Excel window:

1. ALT-F8
2. Select the macro
3. Touch Run



To remove the macro:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

--
Gary''s Student - gsnu200828


"chappy" wrote:

It does contain the word subtotal in column A.
Chappy

"Gary''s Student" wrote:

How can you identify a subtotal row? Does it contain a SUBTOTAL() function in
some column?
--
Gary''s Student - gsnu200828


"chappy" wrote:

I imported data, sorted and subtotalled the data by customer. Is there a way
I can insert a blank row after each subtotal, for readability when I print it
as a report?

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
subtotal blank cells The Rook[_2_] Excel Discussion (Misc queries) 2 September 19th 08 01:16 AM
How do I insert blank rows between rows in completed worksheet? bblue1978 Excel Discussion (Misc queries) 1 October 26th 06 07:02 PM
How do I insert a subtotal? Preacher Ted Excel Discussion (Misc queries) 1 April 26th 06 10:49 PM
Insert Subtotal button Victor Delta Excel Worksheet Functions 0 April 14th 06 08:07 PM
Insert a new worksheet after subtotal KReese Excel Worksheet Functions 1 July 20th 05 10:35 PM


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