Easiest way to get total.

niles08

New Member
Joined
May 17, 2017
Messages
8
I am trying to piece together this Excel spreadsheet to make it easier for our customers to get their totals based on zip code. The biggest issue is that our customers are used to picking their zoning by counties(which we can no longer provide). Switching to zip codes has multiple zip codes in several counties(because of the way the United States is laid out). What I am attempting to create is a basic "check this box" if you want this county and it will total up the zip codes in that county for you and add it to the grand total.

For example, if you want Anoka County, you check the box in the image, and you get 41, because 55038 and 55330 have residents in another county as well that have to be added since it is by zip code. What I need to have happen is when you click on Anoka, this is automated, and you get the 41 automatically added to the total in cell D1. I have un hid all the cells, but my plan is to hide the cells with "zip codes" so that customers are only seeing the cells with the checkboxes. I am having to currently manually go in and change each checkbox to assign it to work individually with the cell next to it, and also change the formulas to match the zip codes below the county(and find the duplicates as well). Is there an easier way, since this is a list of over 1,200 zip codes. I do have the "duplicates" formatted in red so that they are easy to see.

In a perfect world:

When Anoka County was selected, it would add up all of the zip codes below it, AND automatically grab the other 2 zip codes that are duplicated in another county. So 55038 for instance is also found in cell 1182(and has 8 people), so the 8 would be added to the Anoka County total. It is currently doing this, but it was a TON of manual work, before going any further than I have gone I was hoping somebody would have a better suggestion.

Below is a link to the full spreadsheet and the mini sheet which couldn't do all of the sheet but gives a taste. I would greatly appreciate ANY help.

Loading Google Sheets

Total By Zip.xlsx
ABCD
1Total41
2
3Row LabelsCount of ZIP
4ANOKA COUNTYTRUE41
5550051
6550111
7550141
8550384
9553033
10553041
11553306
12554321
13554331
14554481
15554492
16BARNES COUNTYFALSE0
17584811
18BARRON COUNTYFALSE0
19548121
20BAYFIELD COUNTYFALSE0
21548911
22BECKER COUNTYFALSE0
23565012
24565212
25565441
26565545
27565692
28565781
29565851
30565892
31BELTRAMI COUNTYFALSE0
32566011
33BENTON COUNTYFALSE0
42BIG STONE COUNTY55
43562081
44562102
45562116
46562211
47562258
48562278
495624014
50562763
515627812
52BLUE EARTH COUNTY374
5356001103
54560022
555601041
56560249
575603417
585603739
595604812
605605546
61560602
62560629
63560637
645606550
655606812
66560733
67560782
68560803
69560881
705609016
71BOONE COUNTY2
72500361
73501341
74BOYLE COUNTY1
75404221
76BREMER COUNTY1
77506681
78BREVARD COUNTY1
79329011
80BROOKINGS COUNTY3
81570262
82572761
83BROWN COUNTY351
845601925
855604128
86560623
8756073106
88560813
89560835
9056085108
915608762
925626611
93BUENA VISTA COUNTY1
94505681
95BUFFALO COUNTY1
96547551
97BURNETT COUNTY1
98548931
99BUTLER COUNTY3
100506021
101506041
102506651
103CALHOUN COUNTY1
104505631
105CARLTON COUNTY5
106557071
107557491
108557571
109557672
110CARVER COUNTY199
111553153
112553174
1135531816
1145532242
115553282
116553398
1175536015
118553632
119553678
1205536833
121553863
1225538722
1235538816
124553952
1255539718
126560115
127CASS COUNTY15
128564351
129564664
130564681
131564731
132564742
133566261
134580781
135581044
136CEDAR COUNTY1
137522551
138CERRO GORDO COUNTY1
139504281
140CHEROKEE COUNTY3
141510122
142510251
143CHESAPEAKE CITY1
144233201
145CHIPPEWA COUNTY126
146547241
147547292
148562081
1495622226
150562415
151562524
1525626019
153562626
1545626543
155562717
156562829
157562953
158CHISAGO COUNTY9
159550081
160550121
161550131
162550321
163550451
164550561
165550692
166550921
167CLARK COUNTY1
168544361
169CLAY COUNTY60
170513013
171513331
172513431
173565143
174565367
175565462
176565473
177565499
178565523
1795656017
180565805
181565856
182CLAYTON COUNTY2
183520431
184521571
185CLEARWATER COUNTY2
186566441
187566761
188CODINGTON COUNTY1
189572431
190COOK COUNTY1
191604391
192COTTONWOOD COUNTY189
1935601914
1945608314
1955610142
1965611812
197561314
198561377
1995614519
2005615213
2015615937
202561662
203561746
204561802
2055618317
206CROW WING COUNTY19
207563646
208564014
209564252
210564311
211564471
212564483
213564651
214564741
215DAKOTA COUNTY164
2165500910
2175502432
2185503113
2195503342
2205504410
2215505716
222550659
2235506811
224550761
225550772
226550851
227551182
228551202
229551211
230551221
231551232
232551247
233553372
234DALLAS COUNTY4
235502661
236503233
237DENTON COUNTY1
238762101
239DEUEL COUNTY7
240572131
241572183
242572373
243DICKINSON COUNTY13
244513311
245513381
246513475
247513513
248513602
249513641
250DODGE COUNTY112
251539631
252559178
253559201
2545592414
2555592723
2565594015
2575594423
258559462
259559559
260559631
2615598515
262DOUGLAS COUNTY100
263548541
2645630823
2655631512
266563195
2675632614
268563274
269563324
270563391
271563411
272563435
273563546
274563555
2755636014
276563614
277564461
278DUNN COUNTY2
279547512
280EAU CLAIRE COUNTY4
281547011
282547221
283547421
284547701
285EMMET COUNTY11
286505146
287505312
288513342
289513651
290ERIE COUNTY1
291142221
292FARIBAULT COUNTY255
2935601354
2945601424
2955602316
2965602525
2975602711
298560338
299560391
300560516
3015606812
3025609766
3035609832
304FAYETTE COUNTY3
305506292
306521411
307FILLMORE COUNTY166
308559222
3095592312
3105593513
3115593914
3125594919
313559511
3145595411
315559615
3165596211
3175596524
318559716
3195597525
320559764
321559792
3225599017
323FINNEY COUNTY1
324678461
325FLOYD COUNTY2
326504682
327FRANKLIN COUNTY4
328504201
329504411
330504521
331504751
332FREEBORN COUNTY237
3335591212
334559177
335559531
3365600776
3375600937
338560168
3395602613
3405602910
341560321
342560351
3435603632
3445604212
345560437
346560456
347560726
348560978
349GOODHUE COUNTY233
3505500927
3515501813
3525502742
353550331
3545504111
355550537
356550651
3575506621
3585508918
3595594630
360559561
3615596312
3625598312
363559853
3645599234
365GRAND FORKS COUNTY1
366582011
367GRANT COUNTY50
368562489
369562748
370563091
371563111
372563261
3735633910
3745653112
375565905
376572162
377572521
378HAMILTON COUNTY1
379502481
380HAMLIN COUNTY1
381572231
382HANCOCK COUNTY5
383504231
384504301
385504361
386504831
387504841
388HAND COUNTY1
389573621
390HANSON COUNTY1
391573401
392HENNEPIN COUNTY87
393553052
394553112
395553162
396553272
397553313
3985534012
399553461
400553471
401553562
402553575
403553599
404553642
405553692
406553746
407553881
408553911
409554031
410554052
411554063
412554081
413554091
414554101
415554121
416554131
417554151
418554161
419554171
420554181
421554221
422554284
423554313
424554352
425554371
426554381
427554391
428554433
429554461
430554472
431HOUSTON COUNTY56
432363031
4335592119
434559312
435559413
4365594312
437559471
438559541
439559713
4405597414
441HOWARD COUNTY7
442504662
443506282
444521341
445521362
446HUBBARD COUNTY1
447564701
448HUMBOLDT COUNTY2
449505201
450505771
451ISANTI COUNTY38
452550066
453550089
454550173
455550408
456550561
457550701
458550804
459553716
460ITASCA COUNTY4
461557091
462566282
463566361
464JACKSON COUNTY185
4655610113
466561116
4675611912
468561271
4695613718
4705614359
4715615048
472561592
473561602
4745616112
475561675
476561876
477975241
478KANABEC COUNTY16
479550063
480550516
481563587
482KANDIYOHI COUNTY242
4835620168
4845620932
485562168
486562518
487562522
4885625318
4895627326
4905627910
4915628115
4925628217
493562847
4945628815
495562898
496563124
497563624
498KANE COUNTY2
499601241
500601751
501KENOSHA COUNTY1
502531581
503KENT COUNTY1
504493311
505KITTSON COUNTY30
506567288
507567314
508567325
5095673310
510567352
511567551
512KOSSUTH COUNTY22
513504244
514504301
515504512
516505116
517505173
518505564
519505901
520505981
521LA CROSSE COUNTY1
522546361
523LABETTE COUNTY1
524673571
525LAC QUI PARLE COUNTY132
5265621216
5275621810
528562202
529562231
5305623235
5315625648
532562579
533562659
534562761
535562781
536LE SUEUR COUNTY256
537560115
5385601715
5395602812
540560444
5415605013
5425605213
5435605754
5445605833
545560636
5465606939
5475607129
548560828
5495609625
550LEE COUNTY1
551339031
552LINCOLN COUNTY106
553561135
5545613619
5555614225
5565614920
557561641
558561702
5595617827
560562201
561562803
562562912
563831281
564LINN COUNTY1
565523021
566LYON COUNTY239
567512371
568512391
569512411
570512434
571512463
572561131
5735611522
574561329
5755615711
5765616910
577561701
5785617520
579561787
580562201
5815622927
5825623910
5835625883
584562632
5855626421
586562914
587MAHNOMEN COUNTY4
588565572
589565892
590MARICOPA COUNTY2
591850441
592853511
593MARION COUNTY1
594462681
595MARSHALL COUNTY40
596567014
597567101
598567131
599567242
600567253
601567274
602567372
603567383
6045675711
605567581
606567604
607567624
608MARTIN COUNTY246
6095601311
610560271
6115603164
6125603933
6135608826
614560983
615561111
616561217
6175612713
618561603
619561626
6205617137
6215617623
6225618118
623MCLEOD COUNTY278
6245531226
6255533665
626553381
627553392
6285535083
6295535422
630553708
6315538135
6325538519
6335539515
634553961
635553971
636MEEKER COUNTY211
637553249
6385532532
6395532915
640553506
6415535311
6425535560
643553823
6445538926
645562095
6465622815
6475624322
648563627
649MILLE LACS COUNTY39
6505537112
651563305
6525635318
653563573
654563861
655MINNEHAHA COUNTY11
656570031
657570053
658570221
659570681
660571041
661571061
662571103
663MITCHELL COUNTY10
664504553
665504612
666504724
667504761
668MONROE COUNTY1
669546561
670MONTGOMERY COUNTY3
671208541
672515731
673773861
674MOODY COUNTY1
675570261
676MORRISON COUNTY188
6775631413
678563183
679563281
680563296
6815633813
682563403
6835634556
6845636440
6855637326
6865638214
687563841
688564431
689564492
690564759
691MORTON COUNTY1
692585541
693MOWER COUNTY179
6945590924
6955591244
696559176
697559185
698559268
699559333
7005593621
701559401
702559518
703559535
704559613
705559679
7065597011
707559733
7085597712
7095598216
710MURRAY COUNTY164
711561144
7125611512
7135612218
714561237
715561282
7165613131
717561328
718561415
7195615125
720561701
7215617228
722561757
723561804
724561838
725561864
726NATRONA COUNTY1
727826011
728NICOLLET COUNTY256
729553329
730553341
7315533510
7325600341
7335602127
7345605427
735560581
7365607343
7375607443
7385608254
739NOBLES COUNTY189
7405611029
741561175
7425611915
743561223
744561285
745561298
7465613113
747561412
748561471
749561533
Sheet5
Cell Formulas
RangeFormula
D1D1=SUM(D3:D500)
D4D4=IF(C4,SUM(B5:B15)+B112+B1016+B1256,0)
D16,D31,D20,D18D16=IF(C16,B17,0)
D22D22=IF(C22,SUM(B23:B30)+B810+B181+B589,0)
D33D33=IF(C33,SUM(B34:B41)+B1019+B6801+B1020+B651+B653+B1075+B685,0)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A:ACell ValueduplicatestextNO
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Does your county to zip code data come like that? The county and zip codes in the same column? Would it be possible for you to have the county name and zip code in two separate columns, and both columns 100% filled in?
 
Upvote 0
Does your county to zip code data come like that? The county and zip codes in the same column? Would it be possible for you to have the county name and zip code in two separate columns, and both columns 100% filled in?
No, it doesn't this was just a pivot table I created of the two. I just uploaded another version below that has the zip code and the county that zip code belongs on. Since this isn't a pivot yet, there are just over 10,500 records.

Loading Google Sheets
 
Upvote 0
Okay, probably the biggest and most complicated formula i've ever created. So, there is probably a much more elegant way.
I copied the data from your google sheet. I placed dummy values in column C.

Then this formula in cell F2:

Excel Formula:
=LET(
aggregate,HSTACK(
LET(
Countys,$A$2:$A$1120,
Zips,$B$2:$B$1120,
Values,$C$2:$C$1120,
CountyZips,TRANSPOSE(UNIQUE(FILTER(Zips,Countys="ANOKA COUNTY",""))),
matrix,Zips*(CountyZips=Zips),
ZipMatches,BYROW(matrix,LAMBDA(matrix,SUM(matrix))),ZipMatches),
LET(
Countys,$A$2:$A$1120,Zips,$B$2:$B$1120,Values,$C$2:$C$1120,
CountyZips,TRANSPOSE(UNIQUE(FILTER(Zips,Countys="ANOKA COUNTY",""))),
matrix,Zips*(CountyZips=Zips),
ZipMatches,BYROW(matrix,LAMBDA(matrix,SUM(matrix))),
HZipList,TRANSPOSE(FILTER(ZipMatches,ZipMatches>0,"")),
valuematrix,(HZipList=Zips)*Values,
BYROW(valuematrix,LAMBDA(valuematrix,SUM(valuematrix))))),
zipcodes,TAKE(aggregate,,1),
FILTER(aggregate,zipcodes<>0))



Book1
ABCDEFGH
1COUNTYZIP
2ANOKA COUNTY55038345503868
3ANOKA COUNTY55449255544925
4ANOKA COUNTY55330255533075
5ANOKA COUNTY55303205530320
6ANOKA COUNTY55304225530422
7ANOKA COUNTY55448335544833
8ANOKA COUNTY55011345501134
9ANOKA COUNTY55432315543231
10ANOKA COUNTY55005385500538
11ANOKA COUNTY55014405501440
12ANOKA COUNTY55433285543328
13BARNES COUNTY584812655330117
14BARRON COUNTY54812365503850
15BAYFIELD COUNTY54891245533072
16BECKER COUNTY5655435
17BECKER COUNTY5654423
18BECKER COUNTY5658933
19BECKER COUNTY5650135
20BECKER COUNTY5652126
Sheet6
Cell Formulas
RangeFormula
F2:G15F2=LET(aggregate, HSTACK( LET(Countys,$A$2:$A$1120,Zips,$B$2:$B$1120,Values,$C$2:$C$1120,CountyZips,TRANSPOSE(UNIQUE(FILTER(Zips,Countys="ANOKA COUNTY",""))),matrix,Zips*(CountyZips=Zips),ZipMatches,BYROW(matrix,LAMBDA(matrix,SUM(matrix))),ZipMatches), LET(Countys,$A$2:$A$1120,Zips,$B$2:$B$1120,Values,$C$2:$C$1120,CountyZips,TRANSPOSE(UNIQUE(FILTER(Zips,Countys="ANOKA COUNTY",""))),matrix,Zips*(CountyZips=Zips),ZipMatches,BYROW(matrix,LAMBDA(matrix,SUM(matrix))),HZipList,TRANSPOSE(FILTER(ZipMatches,ZipMatches>0,"")),valuematrix,(HZipList=Zips)*Values, BYROW(valuematrix,LAMBDA(valuematrix,SUM(valuematrix))))), zipcodes,TAKE(aggregate,,1),FILTER(aggregate,zipcodes<>0))
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,198
Members
452,616
Latest member
intern444

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