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
 
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 .

Because my function can be entered in one cell, and copied for the 100 col answers required. Yours can't.
 
Upvote 0

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Good point , im getting zero 0 as answer when your two functions are Put into cells DI2 and DJ2 .
Thanks .
 
Upvote 0
More appoligies i didnt put the 1/1= or 2/2= into cells DI1 and DJ2 .
The function is returning an answer but not the correct one .
On a sample of 2281 rows i filtered for 1 or 1= and this is not matching what is in DI1 or DJ2 .
Thanks for your patience .
 
Upvote 0
Ok i finally figured it out i needed to change the 999 part of the function too 9999 .
Thanks for all your help GlennUK and your patience with me on this one .
Thankyou .
 
Upvote 0
That's great that it's working now :-) My pleasure to help.
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

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