Trouble with calculations in Excel table

Hey,

I have a table of number sof high-rise buildings in the US (attached here). What I'm trying to do (with formula or code) is to compute how many buildings there are (in all the US) with 14 floors. How many with 15 floors. Etc. with each number of floors. I am beginner-level with VBA. I started by sorting everything according to number of floors, then writing a For loop to go through the rows and start adding the numbers, but I ran into trouble that I didn't know how to handle (know when it's the first instance of that number of floors in order to start counting anew form there, etc.). You can see my code (very preliminary) in the file.

I need something like this (for all numbers of floors):

14 floors - 400 (buildings)
15 floors - 250
...

After that, I also need to do the same thing, but this time divided by States, meaning:

AK:
14 floors - 100
15 floors - 50
(for each state and for each number of floors)

I would be really glad for help with this issue.. too many little details that I'm not sure how to handle.
Thanks a lot!

AttachmentSize
Completed_USA_12plus_by_city_floors_usagecategory.xls725 KB

Thanks

Thank you, that indeed did the trick.

Almir's picture

Use pivot table

You can accomplish this using pivot table. Just assign a name to X column (X1 cell). Create pivot table, as following: State and no. of floors as rows and sum of total no. of buildings as summary value.