VBA to Keep Subtotal Groupings Based on Conditional Formatting

LtCmdrData

Board Regular
Joined
Jan 24, 2018
Messages
58
Office Version
  1. 365
Platform
  1. Windows
Hello All,

I have some data subtotaled by various quantities (columns N & O subtotaled by column B) . The number of subtotaled rows varies. Sometimes it may be only row, other instances it may be 4-5 rows subtotaled. I have applied conditional formatting in a couple of columns (N, O, & S) to highlight when quantities exceed certain limits or changes have occurred. It might highlight a quantity in a data row, a subtotal amount, or both. All of this I have VBA code for.

Here is where I need help please. At this point I want to remove all the rows of data that do not have conditional formatting but I want to keep all rows associated with a subtotal grouping even if that row does not contain conditional formatting. I don't know how to code to keep the groupings. All the columns have data, I have just removed the data in most columns to keep things generic. Below I have my conditional formatted data bold and in yellow. I apologize for the crude example but hope it conveys the idea. Can someone offer suggestions and/or solutions? Thank you.

A B C D E F G H I J K L M N O P Q R S
Booking NumberLoad NumberCustomer ChargeOrigin NameOrigin CityOrigin StateOrigin ZipTarget Ship (Early)Dest NameDest CityDest StateDest ZipTarget Delivery (Early)PalletWeightCubeTypeLookupDiff
247613L56941005/25/2021 00:0005/27/2021 00:00
13​
17,122​
17121.5​
0​
247614L56941005/25/2021 00:0005/27/2021 00:00
16​
19,672​
19671.5​
0​
L569410 Total
29​
36,793​
246903L56939605/24/2021 00:0005/25/2021 00:00
2​
1,824​
1823.7​
0​
246953L56939605/24/2021 00:0005/25/2021 00:00
4​
3,958​
3958​
0​
247276L56939605/24/2021 00:0005/25/2021 00:00
4​
7,236​
7236​
0​
247277L56939605/24/2021 00:0005/25/2021 00:00
3​
4,159​
4732​
-573
247278L56939605/24/2021 00:0005/25/2021 00:00
2​
1,927​
1926.8​
0​
L569396 Total
15​
19,104​
246975L56939505/25/2021 00:0005/25/2021 00:00
17​
27,951​
27951​
0​
247279L56939505/25/2021 00:0005/25/2021 00:00
9​
13,394​
13393.6​
0​
L569395 Total
26​
41,345​
247072L56939405/25/2021 00:0005/26/2021 00:00
13​
20,320​
20320.1​
0​
247073L56939405/25/2021 00:0005/26/2021 00:00
16​
22,927​
22926.6​
0​
L569394 Total
29​
43,247
247271L56939305/24/2021 00:0005/25/2021 00:00
28​
15,941​
15941.4​
0​
L569393 Total
28​
15,941​
247377L56939205/26/2021 00:0005/27/2021 00:00
29​
18,167​
18166.8​
0​
247379L56939205/26/2021 00:0005/27/2021 00:00
2​
2,431​
2431.4​
0​
247435L56939205/26/2021 00:0005/27/2021 00:00
1​
175​
175​
0​
L569392 Total
32
20,773​
247434L56939105/27/2021 00:0005/28/2021 00:00
28​
17,869​
17869.4​
0​
L569391 Total
28​
17,869​
246425L56939005/25/2021 00:0005/26/2021 00:00
10​
10,488​
10487.6​
0​
247272L56939005/25/2021 00:0005/26/2021 00:00
16​
21,416​
21415.8​
0​
L569390 Total
26​
31,903​
247104L56938305/25/2021 00:0005/27/2021 00:00
1​
885​
885​
0​
247221L56938305/25/2021 00:0005/27/2021 00:00
9​
16,861​
16861​
0​
247230L56938305/25/2021 00:0005/27/2021 00:00
18​
28,228​
24330.3​
3898
L569383 Total
28​
45,974
247400L56938205/25/2021 00:0005/27/2021 00:00
15​
19,983​
19670​
312.5
247418L56938205/25/2021 00:0005/26/2021 00:00
10​
12,345​
12345​
0​
247520L56938205/25/2021 00:0005/27/2021 00:00
2​
1,954​
1954.2​
0​
L569382 Total
27​
34,282​
246572L56938005/26/2021 00:0005/27/2021 00:00
8​
7,832​
7831.5​
0​
247124L56938005/26/2021 00:0005/27/2021 00:00
2​
2,027​
2026.8​
0​
247580L56938005/26/2021 00:0005/27/2021 00:00
20​
23,710​
23710​
0​
L569380 Total
30​
33,568​
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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