excel countif filtered by style












3















I have an Excel spreadsheet and I'm trying to count rows in a column based on a style applied to some cells in the column. Is there a simple way to do this?










share|improve this question



























    3















    I have an Excel spreadsheet and I'm trying to count rows in a column based on a style applied to some cells in the column. Is there a simple way to do this?










    share|improve this question

























      3












      3








      3








      I have an Excel spreadsheet and I'm trying to count rows in a column based on a style applied to some cells in the column. Is there a simple way to do this?










      share|improve this question














      I have an Excel spreadsheet and I'm trying to count rows in a column based on a style applied to some cells in the column. Is there a simple way to do this?







      microsoft-excel countif






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 18 '12 at 2:06









      Bill WeinmanBill Weinman

      17316




      17316






















          2 Answers
          2






          active

          oldest

          votes


















          2














          No, not really. You could use Visual Basic to access cell formatting properties but most inbuilt functions that you would type into a cell focus on the cell contents, not the formatting.



          If your styles have different shading colours then you can use the following method.



          Step 1: Convert your range to a list and then adding a total row showing COUNT



          enter image description here



          Step 2: Apply a colour filter (should work on Excel 2007 and later):



          enter image description here



          Done: The COUNT total will show the filtered number of rows.



          enter image description here






          share|improve this answer
























          • I would have preferred an answer that said, "of course you can! here's how to do it!" but, alas, you're probably right. There's no way to do what I want without using VB. Thanks.

            – Bill Weinman
            May 3 '12 at 18:24



















          0














          You could use VBA for that:



          Function CountStyle(CellRange)
          Dim Item As Range, Total As Long
          For Each Item In CellRange
          ' Check to see if the cell is formatted as Style = "Neutral"
          If Item.Style = "Neutral" Then
          Total = Total + 1
          End If
          Next Item
          CountStyle = Total
          End Function


          Taken from here.




          1. Press Alt+F11 to start the Visual Basic editor.

          2. Insert > Module

          3. Insert above code

          4. Go to Excel and choose the cell, where the result should be in. Write e.g. =CountStyle (B4:B23)


          Now you have count all cells with the style Neutral. I've created three functions for neutral, good, bad. This looks like:



          Function CountStyleGood(CellRange)
          Dim Item As Range, Total As Long
          For Each Item In CellRange
          ' Check to see if the cell is formatted as Style = "Good"
          If Item.Style = "Good" Then
          Total = Total + 1
          End If
          Next Item
          CountStyleGood = Total
          End Function


          Wit =CountStyleGood(B4:B23) you get the result. As name of the style I've used the name displayed in the ribbon.






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f413697%2fexcel-countif-filtered-by-style%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            No, not really. You could use Visual Basic to access cell formatting properties but most inbuilt functions that you would type into a cell focus on the cell contents, not the formatting.



            If your styles have different shading colours then you can use the following method.



            Step 1: Convert your range to a list and then adding a total row showing COUNT



            enter image description here



            Step 2: Apply a colour filter (should work on Excel 2007 and later):



            enter image description here



            Done: The COUNT total will show the filtered number of rows.



            enter image description here






            share|improve this answer
























            • I would have preferred an answer that said, "of course you can! here's how to do it!" but, alas, you're probably right. There's no way to do what I want without using VB. Thanks.

              – Bill Weinman
              May 3 '12 at 18:24
















            2














            No, not really. You could use Visual Basic to access cell formatting properties but most inbuilt functions that you would type into a cell focus on the cell contents, not the formatting.



            If your styles have different shading colours then you can use the following method.



            Step 1: Convert your range to a list and then adding a total row showing COUNT



            enter image description here



            Step 2: Apply a colour filter (should work on Excel 2007 and later):



            enter image description here



            Done: The COUNT total will show the filtered number of rows.



            enter image description here






            share|improve this answer
























            • I would have preferred an answer that said, "of course you can! here's how to do it!" but, alas, you're probably right. There's no way to do what I want without using VB. Thanks.

              – Bill Weinman
              May 3 '12 at 18:24














            2












            2








            2







            No, not really. You could use Visual Basic to access cell formatting properties but most inbuilt functions that you would type into a cell focus on the cell contents, not the formatting.



            If your styles have different shading colours then you can use the following method.



            Step 1: Convert your range to a list and then adding a total row showing COUNT



            enter image description here



            Step 2: Apply a colour filter (should work on Excel 2007 and later):



            enter image description here



            Done: The COUNT total will show the filtered number of rows.



            enter image description here






            share|improve this answer













            No, not really. You could use Visual Basic to access cell formatting properties but most inbuilt functions that you would type into a cell focus on the cell contents, not the formatting.



            If your styles have different shading colours then you can use the following method.



            Step 1: Convert your range to a list and then adding a total row showing COUNT



            enter image description here



            Step 2: Apply a colour filter (should work on Excel 2007 and later):



            enter image description here



            Done: The COUNT total will show the filtered number of rows.



            enter image description here







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Apr 18 '12 at 8:31









            Mike FitzpatrickMike Fitzpatrick

            14.4k33540




            14.4k33540













            • I would have preferred an answer that said, "of course you can! here's how to do it!" but, alas, you're probably right. There's no way to do what I want without using VB. Thanks.

              – Bill Weinman
              May 3 '12 at 18:24



















            • I would have preferred an answer that said, "of course you can! here's how to do it!" but, alas, you're probably right. There's no way to do what I want without using VB. Thanks.

              – Bill Weinman
              May 3 '12 at 18:24

















            I would have preferred an answer that said, "of course you can! here's how to do it!" but, alas, you're probably right. There's no way to do what I want without using VB. Thanks.

            – Bill Weinman
            May 3 '12 at 18:24





            I would have preferred an answer that said, "of course you can! here's how to do it!" but, alas, you're probably right. There's no way to do what I want without using VB. Thanks.

            – Bill Weinman
            May 3 '12 at 18:24













            0














            You could use VBA for that:



            Function CountStyle(CellRange)
            Dim Item As Range, Total As Long
            For Each Item In CellRange
            ' Check to see if the cell is formatted as Style = "Neutral"
            If Item.Style = "Neutral" Then
            Total = Total + 1
            End If
            Next Item
            CountStyle = Total
            End Function


            Taken from here.




            1. Press Alt+F11 to start the Visual Basic editor.

            2. Insert > Module

            3. Insert above code

            4. Go to Excel and choose the cell, where the result should be in. Write e.g. =CountStyle (B4:B23)


            Now you have count all cells with the style Neutral. I've created three functions for neutral, good, bad. This looks like:



            Function CountStyleGood(CellRange)
            Dim Item As Range, Total As Long
            For Each Item In CellRange
            ' Check to see if the cell is formatted as Style = "Good"
            If Item.Style = "Good" Then
            Total = Total + 1
            End If
            Next Item
            CountStyleGood = Total
            End Function


            Wit =CountStyleGood(B4:B23) you get the result. As name of the style I've used the name displayed in the ribbon.






            share|improve this answer




























              0














              You could use VBA for that:



              Function CountStyle(CellRange)
              Dim Item As Range, Total As Long
              For Each Item In CellRange
              ' Check to see if the cell is formatted as Style = "Neutral"
              If Item.Style = "Neutral" Then
              Total = Total + 1
              End If
              Next Item
              CountStyle = Total
              End Function


              Taken from here.




              1. Press Alt+F11 to start the Visual Basic editor.

              2. Insert > Module

              3. Insert above code

              4. Go to Excel and choose the cell, where the result should be in. Write e.g. =CountStyle (B4:B23)


              Now you have count all cells with the style Neutral. I've created three functions for neutral, good, bad. This looks like:



              Function CountStyleGood(CellRange)
              Dim Item As Range, Total As Long
              For Each Item In CellRange
              ' Check to see if the cell is formatted as Style = "Good"
              If Item.Style = "Good" Then
              Total = Total + 1
              End If
              Next Item
              CountStyleGood = Total
              End Function


              Wit =CountStyleGood(B4:B23) you get the result. As name of the style I've used the name displayed in the ribbon.






              share|improve this answer


























                0












                0








                0







                You could use VBA for that:



                Function CountStyle(CellRange)
                Dim Item As Range, Total As Long
                For Each Item In CellRange
                ' Check to see if the cell is formatted as Style = "Neutral"
                If Item.Style = "Neutral" Then
                Total = Total + 1
                End If
                Next Item
                CountStyle = Total
                End Function


                Taken from here.




                1. Press Alt+F11 to start the Visual Basic editor.

                2. Insert > Module

                3. Insert above code

                4. Go to Excel and choose the cell, where the result should be in. Write e.g. =CountStyle (B4:B23)


                Now you have count all cells with the style Neutral. I've created three functions for neutral, good, bad. This looks like:



                Function CountStyleGood(CellRange)
                Dim Item As Range, Total As Long
                For Each Item In CellRange
                ' Check to see if the cell is formatted as Style = "Good"
                If Item.Style = "Good" Then
                Total = Total + 1
                End If
                Next Item
                CountStyleGood = Total
                End Function


                Wit =CountStyleGood(B4:B23) you get the result. As name of the style I've used the name displayed in the ribbon.






                share|improve this answer













                You could use VBA for that:



                Function CountStyle(CellRange)
                Dim Item As Range, Total As Long
                For Each Item In CellRange
                ' Check to see if the cell is formatted as Style = "Neutral"
                If Item.Style = "Neutral" Then
                Total = Total + 1
                End If
                Next Item
                CountStyle = Total
                End Function


                Taken from here.




                1. Press Alt+F11 to start the Visual Basic editor.

                2. Insert > Module

                3. Insert above code

                4. Go to Excel and choose the cell, where the result should be in. Write e.g. =CountStyle (B4:B23)


                Now you have count all cells with the style Neutral. I've created three functions for neutral, good, bad. This looks like:



                Function CountStyleGood(CellRange)
                Dim Item As Range, Total As Long
                For Each Item In CellRange
                ' Check to see if the cell is formatted as Style = "Good"
                If Item.Style = "Good" Then
                Total = Total + 1
                End If
                Next Item
                CountStyleGood = Total
                End Function


                Wit =CountStyleGood(B4:B23) you get the result. As name of the style I've used the name displayed in the ribbon.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Oct 18 '16 at 19:36









                testingtesting

                33141125




                33141125






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Super User!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f413697%2fexcel-countif-filtered-by-style%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How do I know what Microsoft account the skydrive app is syncing to?

                    When does type information flow backwards in C++?

                    Grease: Live!