Group rows based on contents of two columns

MurrayBarn

New Member
Joined
May 27, 2012
Messages
32
Office Version
  1. 365
Platform
  1. Windows
I have a spreadsheet that is an income statement for the year with each month showing separately in its own column. The budgeted figures are also shown monthly per column. On the far right, I have a total for both Actual (in column AO) and Budget (AP). I am trying to find a macro code that will Group all rows that both AO and AP are zero. The formulas in AO are =C3+F3+I3..... for twelve months. The Budget total has a similar formula but refers to the columns just to the right of the Actual columns.

I am new at Macros and have found a lot of macros that have very complicated range definitions etc and I cant get any to work for me. The row range is 9:300.

I could really do with some help to firstly Ungroup any rows that were previously Grouped and then to Group the rows that fit the above definition. Also, I have multiple spreadsheets and I need this done for all four. Their names could be Apple, Orange, Pear and Banana

Please help somebody!
 
Re: Maybe I've got it.

Got it!!! The Cells.ClearOutline is in the Loop. I have taken it out and it works!!
It will have to be inside to clear each page out if you rerun it.
Could you please explain a little more how the Split() function works. For instance, if I have four Worksheets that have data I want to view and another four data worksheets, I assume that if I define them as you have, it will only work on the sheets defined?
That is correct. But there are several ways to loop through all, or selective worksheets. This is just one.

Split just takes a string of characters, separated by a delimiter, a comma in this instance, and creates an array.

So instead of
MyArray(1) = "Sheet1"
MyArray(2) = "Sheet2"
MyArray(3) = "Sheet3"

We can use the split function. Then in association with the ubound (this tells us how many elements are in the array), we now know how many loops to perform.
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,215,731
Messages
6,126,539
Members
449,316
Latest member
sravya

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top