Full Version: Grouping
UtterAccess Discussion Forums > Microsoft® Office > Microsoft Excel
Spankyjumunkwa
I have 2000 invoices, each with anywhere from 1 to 300 lines that I need to group by invoice number. Is there a way to do this where I don't have to group each invoice individually?

Second question. Can I insert a blank row after each group?

I really appreciate any input.
NateO
Hello Spanky,

1) Yes, select your data and sort it, Data->Sort

2) See the following:

Sub insrtRows()
[color="#00007F"]Dim i [color="#00007F"]As [color="#00007F"]Long
Application.ScreenUpdating = 0
[color="#00007F"]For i = [a65536].End(3).Row [color="#00007F"]To 2 [color="#00007F"]Step -1
[color="#00007F"]With Cells(i, 1)
[color="#00007F"]If .Value <> .Item(0).Value [color="#00007F"]Then .EntireRow.Insert
[color="#00007F"]End [color="#00007F"]With
[color="#00007F"]Next
Application.ScreenUpdating = -1
[color="#00007F"]End [color="#00007F"]Sub


[color="#00007F"]Sub remRows()
[color="#00007F"]On [color="#00007F"]Error [color="#00007F"]Resume [color="#00007F"]Next
[a:a].SpecialCells(xlBlanks).EntireRow.Delete
[color="#00007F"]End [color="#00007F"]Sub


Hope this helps.
Spankyjumunkwa
I will try this, but I don't know how to use VBA. Is there a non-code way to do this? I appreciate the help.
Spankyjumunkwa
When I click on the Visual Basic Editor, there is no blank page displayed, only grey area...
NateO
Hello again Spanky,

Not for number 2 that does not involve manually looking through each cell and inserting.

May be an opportune time to expand the horizons and dabble with vba eh?
NateO
Yes, you need to insert a module. Insert->Module. Make sure it's in the correct workbook. Copy the code from the board and paste it either into a blank sheet or Word before pasting it into the Module.

Bon chance.
Spankyjumunkwa
I wouldn't even call it dabbling, just copying and pasting what others write...

How do I get to a place where I can use this code?

I didn't explain myself very well for #1. Not only do I want to group them, but be able to shrink them, I think using an outline? Can I apply an outline individually to each invoice at the same time?
Spankyjumunkwa
Ok, I got the rows added. Thank you. That takes care of one part of the problem.

The grouping isn't as important, but I have another question for you. Can I insert a function into the blank rows that I just inserted? If I want to sum up column J in the blank row I just added, how do I write that?

Thanks again for your help.
NateO
Hello,

You can do this... Have you looked at the native Subtotals functionality? Should be under the Data menu header, might want to have a go with this.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.