Macro to count and sub total columns

Sunline

Well-known Member
Joined
Oct 6, 2007
Messages
701
Office Version
  1. 2016
Platform
  1. Windows
Hello all , i was wanting to know if i could get a macro to count and subtotal cols CY:DH individually , looking at col CY there are two 1,s , return answer to col EN 2 ,
Col CY there is one number 2 , return answer to col EO 1 .
Col CY there is one 3= , return answer to col EP 1 .
Col CY there is one 4 , return answer to col EQ 1 .
Col CY there are no 5 or 6 , return answer to col ER and ES zero 0 .
Col CY there is one 7 , return answer to col ET 1 .
Col CY there are no 8 or 9 , return answer to col EU and EV zero 0 .
Col CY there is one 10 , return answer to col EW 1 .

Then move to col CZ and repeat above returning answers to cols EX:FG .
Then repeat for all cols in range CY:DH , ending up with 100 cols up that will have answers .
I have tried using count but as i have close to 180,000 rows comp cant process it all .
Notice blank cells and also may contain text .
Thanks .
Excel Workbook
CYCZDADBDCDDDEDFDGDHENEOEPEQERESETEUEVEWEXEYEZFAFBFCFDFEFFFG
1PL10PL9PL8PL7PL6PL5PL4PL3PL2PL11/1=2/2=3/3=4/4=5/5=6/6=7/7=8/8=9/9=10/10=1/1=2/2=3/3=4/4=5/5=6/6=7/7=8/8=9/9=10/10=
2181631782121110010013111010100
3106162246122=21110010013111010100
4*******82321110010013111010100
5449151=564421110010013111010100
6**********21110010013111010100
7*31155111221110010013111010100
81114132618911P21110010013111010100
93=252616857=21110010013111010100
1021=5314347321110010013111010100
11*****1242121110010013111010100
12**12526114121110010013111010100
13713195871521110010013111010100
14*18=132313=2721110010013111010100
15**********21110010013111010100
Sheet1


Excel Workbook
CYCZDADBDCDDDEDFDGDHENEOEPEQERESETEUEVEWEXEYEZFAFBFCFDFEFFFG
1PL10PL9PL8PL7PL6PL5PL4PL3PL2PL11/1=2/2=3/3=4/4=5/5=6/6=7/7=8/8=9/9=10/10=1/1=2/2=3/3=4/4=5/5=6/6=7/7=8/8=9/9=10/10=
2181631782121110010013111010100
3106162246122=21110010013111010100
4*******82321110010013111010100
5449151=564421110010013111010100
6**********21110010013111010100
7*31155111221110010013111010100
81114132618911P21110010013111010100
93=252616857=21110010013111010100
1021=5314347321110010013111010100
11*****1242121110010013111010100
12**12526114121110010013111010100
13713195871521110010013111010100
14*18=132313=2721110010013111010100
15**********21110010013111010100
Sheet1


Excel Workbook
CYCZDADBDCDDDEDFDGDHENEOEPEQERESETEUEVEWEXEYEZFAFBFCFDFEFFFG
1PL10PL9PL8PL7PL6PL5PL4PL3PL2PL11/1=2/2=3/3=4/4=5/5=6/6=7/7=8/8=9/9=10/10=1/1=2/2=3/3=4/4=5/5=6/6=7/7=8/8=9/9=10/10=
2181631782121110010013111010100
3106162246122=21110010013111010100
4*******82321110010013111010100
5449151=564421110010013111010100
6**********21110010013111010100
7*31155111221110010013111010100
81114132618911P21110010013111010100
93=252616857=21110010013111010100
1021=5314347321110010013111010100
11*****1242121110010013111010100
12**12526114121110010013111010100
13713195871521110010013111010100
14*18=132313=2721110010013111010100
15**********21110010013111010100
Sheet1


Excel Workbook
CYCZDADBDCDDDEDFDGDHENEOEPEQERESETEUEVEWEXEYEZFAFBFCFDFEFFFG
1PL10PL9PL8PL7PL6PL5PL4PL3PL2PL11/1=2/2=3/3=4/4=5/5=6/6=7/7=8/8=9/9=10/10=1/1=2/2=3/3=4/4=5/5=6/6=7/7=8/8=9/9=10/10=
2181631782121110010013111010100
3106162246122=21110010013111010100
4*******82321110010013111010100
5449151=564421110010013111010100
6**********21110010013111010100
7*31155111221110010013111010100
81114132618911P21110010013111010100
93=252616857=21110010013111010100
1021=5314347321110010013111010100
11*****1242121110010013111010100
12**12526114121110010013111010100
13713195871521110010013111010100
14*18=132313=2721110010013111010100
15**********21110010013111010100
Sheet1


Excel Workbook
CYCZDADBDCDDDEDFDGDHENEOEPEQERESETEUEVEWEXEYEZFAFBFCFDFEFFFG
1PL10PL9PL8PL7PL6PL5PL4PL3PL2PL11/1=2/2=3/3=4/4=5/5=6/6=7/7=8/8=9/9=10/10=1/1=2/2=3/3=4/4=5/5=6/6=7/7=8/8=9/9=10/10=
2181631782121110010013111010100
3106162246122=21110010013111010100
4*******82321110010013111010100
5449151=564421110010013111010100
6**********21110010013111010100
7*31155111221110010013111010100
81114132618911P21110010013111010100
93=252616857=21110010013111010100
1021=5314347321110010013111010100
11*****1242121110010013111010100
12**12526114121110010013111010100
13713195871521110010013111010100
14*18=132313=2721110010013111010100
15**********21110010013111010100
Sheet1
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
You say:
I have tried using count but as i have close to 180,000 rows comp cant process it all .

Are you saying that the subtotalling has to cover that entire range? ( i.e. count all the 1's and 1='s in range CY1:CY180000 etc etc )? Also, that would give 1 row of results ... but your output area has results for all rows ... explain what's going on there?
 
Upvote 0
Hi , firstly sorry about all the HTML tables i posted , should of been one only .
I did initially write 100 countifs i think is was but knew realistically it couldnt process all that over the entire 180,000 rows , hopefull thinking on my part . That was the ultimate result i wanted .
I wont be expecting it too run from CY1:CY180000 now though .
I greatfully have some macros from here which can cut the sheet down into currently 169 different sections which could contain just 18 rows or up too approx 50,000 rows per section , it varies .
The reason i want it too populate the answer to entire col is because i will then be filtering only a certain number from another col .

I may be asking way to much here im not sure . Even if this cant be done , having just being able to do too answering the cols EN:EW would be a start and maybe i could add more to macro if i can figure that out .
Thanks .
 
Upvote 0
The reason i want it too populate the answer to entire col is because i will then be filtering only a certain number from another col .
... you'll have to explain that. You only have one row of results ... explain why you need them replicated up to 50000 times.
 
Upvote 0
Ok i think im starting to see your point here .
In col V i would then be filtering 1 or 1= , so therefore as your pointing out i probably only need answers to be put into the rows of cells that match 1 or 1= in col V .
Thanks .
 
Upvote 0
You only need answers in one row ... the answers bear no relationship positionally to the source data. I don't know what you mean by "i probably only need answers to be put into the rows of cells that match 1 or 1= in col V . "
 
Upvote 0
Bump , i only need answers in one row .
Thanks for advice so far .
 
Upvote 0
Have a look at this:
Excel Workbook
CYCZDADBDCDDDEDFDGDHDIDJ
1PL10PL9PL8PL7PL6PL5PL4PL3PL2PL11/1=2/2=
2181631782121
3106162246122=
42823
5449151=5644
61=
Sheet
 
Upvote 0
Im not sure why such a long function would be needed if i can do the same with this .
=SUM(COUNTIF(CY2:CY2282,{"1","1="}))

I was hoping to get a macro based on the above simple function to cover the 100 col answers required .

Thankyou for you help .
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,292
Members
452,902
Latest member
Knuddeluff

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