How do I count cells with in a range in excel with specific value that has a comment using vba or formula?











up vote
1
down vote

favorite












I need help on this. I'm doing a report and inserting comments on cells. How do I count cells with in a range in excel with specific value that has a comment using vba or formula?










share|improve this question




























    up vote
    1
    down vote

    favorite












    I need help on this. I'm doing a report and inserting comments on cells. How do I count cells with in a range in excel with specific value that has a comment using vba or formula?










    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I need help on this. I'm doing a report and inserting comments on cells. How do I count cells with in a range in excel with specific value that has a comment using vba or formula?










      share|improve this question















      I need help on this. I'm doing a report and inserting comments on cells. How do I count cells with in a range in excel with specific value that has a comment using vba or formula?







      excel-vba vba excel






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 9 at 19:34









      Community

      11




      11










      asked Nov 4 '15 at 19:33









      DMac

      83




      83
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          Here is one way. It loops through each cell you pass in the range and checks if there is a comment. If so, it adds it to a counter. This is probably going to be pretty expensive if used on large range, but it should at least get you started:



          Add to a regular module:



          Function CommentCounter(rng As Range) As Integer
          Dim cell As Range
          Dim counter As Integer
          Dim currentComment As String


          For Each cell In rng
          On Error Resume Next
          currentComment = cell.Comment.Text
          If Len(currentComment) > 0 Then counter = counter + 1
          currentComment = ""
          Next cell

          CommentCounter = counter
          End Function


          Just saw the part about having a specific value AND a comment. This should get you going:



          Function CommentCounter(rng As Range) As Integer
          Dim cell As Range
          Dim counter As Integer
          Dim currentComment As String
          Dim specificValue As String

          specificValue = "Something Specific"


          For Each cell In rng
          On Error Resume Next
          currentComment = cell.Comment.Text
          If cell.Value = specificValue And Len(currentComment) > 0 Then counter = counter + 1
          currentComment = ""
          Next cell

          CommentCounter = counter
          End Function





          share|improve this answer





















          • It worked! thanks a lot!
            – DMac
            Nov 5 '15 at 16:57


















          up vote
          0
          down vote













          =COUNTIF(A:A;"comment")


          Where A:A specifies that you want to examine the whole column of A. Instead of A:A, you could also use A1:A3, which means examine A1, A2 and A3.



          EDIT:



          If you want to count the cells with comments (not with the word "comment"), I would suggest to do the following:



          =COUNT(A1:A3) - COUNTBLANK(A1:A3)





          share|improve this answer























          • i don't think the OP means has the word "comment" in a cell, but is actually a comment (little red triangle @ the top right of the cell).
            – sous2817
            Nov 4 '15 at 19:43











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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',
          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%2fstackoverflow.com%2fquestions%2f33530472%2fhow-do-i-count-cells-with-in-a-range-in-excel-with-specific-value-that-has-a-com%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








          up vote
          1
          down vote



          accepted










          Here is one way. It loops through each cell you pass in the range and checks if there is a comment. If so, it adds it to a counter. This is probably going to be pretty expensive if used on large range, but it should at least get you started:



          Add to a regular module:



          Function CommentCounter(rng As Range) As Integer
          Dim cell As Range
          Dim counter As Integer
          Dim currentComment As String


          For Each cell In rng
          On Error Resume Next
          currentComment = cell.Comment.Text
          If Len(currentComment) > 0 Then counter = counter + 1
          currentComment = ""
          Next cell

          CommentCounter = counter
          End Function


          Just saw the part about having a specific value AND a comment. This should get you going:



          Function CommentCounter(rng As Range) As Integer
          Dim cell As Range
          Dim counter As Integer
          Dim currentComment As String
          Dim specificValue As String

          specificValue = "Something Specific"


          For Each cell In rng
          On Error Resume Next
          currentComment = cell.Comment.Text
          If cell.Value = specificValue And Len(currentComment) > 0 Then counter = counter + 1
          currentComment = ""
          Next cell

          CommentCounter = counter
          End Function





          share|improve this answer





















          • It worked! thanks a lot!
            – DMac
            Nov 5 '15 at 16:57















          up vote
          1
          down vote



          accepted










          Here is one way. It loops through each cell you pass in the range and checks if there is a comment. If so, it adds it to a counter. This is probably going to be pretty expensive if used on large range, but it should at least get you started:



          Add to a regular module:



          Function CommentCounter(rng As Range) As Integer
          Dim cell As Range
          Dim counter As Integer
          Dim currentComment As String


          For Each cell In rng
          On Error Resume Next
          currentComment = cell.Comment.Text
          If Len(currentComment) > 0 Then counter = counter + 1
          currentComment = ""
          Next cell

          CommentCounter = counter
          End Function


          Just saw the part about having a specific value AND a comment. This should get you going:



          Function CommentCounter(rng As Range) As Integer
          Dim cell As Range
          Dim counter As Integer
          Dim currentComment As String
          Dim specificValue As String

          specificValue = "Something Specific"


          For Each cell In rng
          On Error Resume Next
          currentComment = cell.Comment.Text
          If cell.Value = specificValue And Len(currentComment) > 0 Then counter = counter + 1
          currentComment = ""
          Next cell

          CommentCounter = counter
          End Function





          share|improve this answer





















          • It worked! thanks a lot!
            – DMac
            Nov 5 '15 at 16:57













          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          Here is one way. It loops through each cell you pass in the range and checks if there is a comment. If so, it adds it to a counter. This is probably going to be pretty expensive if used on large range, but it should at least get you started:



          Add to a regular module:



          Function CommentCounter(rng As Range) As Integer
          Dim cell As Range
          Dim counter As Integer
          Dim currentComment As String


          For Each cell In rng
          On Error Resume Next
          currentComment = cell.Comment.Text
          If Len(currentComment) > 0 Then counter = counter + 1
          currentComment = ""
          Next cell

          CommentCounter = counter
          End Function


          Just saw the part about having a specific value AND a comment. This should get you going:



          Function CommentCounter(rng As Range) As Integer
          Dim cell As Range
          Dim counter As Integer
          Dim currentComment As String
          Dim specificValue As String

          specificValue = "Something Specific"


          For Each cell In rng
          On Error Resume Next
          currentComment = cell.Comment.Text
          If cell.Value = specificValue And Len(currentComment) > 0 Then counter = counter + 1
          currentComment = ""
          Next cell

          CommentCounter = counter
          End Function





          share|improve this answer












          Here is one way. It loops through each cell you pass in the range and checks if there is a comment. If so, it adds it to a counter. This is probably going to be pretty expensive if used on large range, but it should at least get you started:



          Add to a regular module:



          Function CommentCounter(rng As Range) As Integer
          Dim cell As Range
          Dim counter As Integer
          Dim currentComment As String


          For Each cell In rng
          On Error Resume Next
          currentComment = cell.Comment.Text
          If Len(currentComment) > 0 Then counter = counter + 1
          currentComment = ""
          Next cell

          CommentCounter = counter
          End Function


          Just saw the part about having a specific value AND a comment. This should get you going:



          Function CommentCounter(rng As Range) As Integer
          Dim cell As Range
          Dim counter As Integer
          Dim currentComment As String
          Dim specificValue As String

          specificValue = "Something Specific"


          For Each cell In rng
          On Error Resume Next
          currentComment = cell.Comment.Text
          If cell.Value = specificValue And Len(currentComment) > 0 Then counter = counter + 1
          currentComment = ""
          Next cell

          CommentCounter = counter
          End Function






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 4 '15 at 19:53









          sous2817

          3,40222330




          3,40222330












          • It worked! thanks a lot!
            – DMac
            Nov 5 '15 at 16:57


















          • It worked! thanks a lot!
            – DMac
            Nov 5 '15 at 16:57
















          It worked! thanks a lot!
          – DMac
          Nov 5 '15 at 16:57




          It worked! thanks a lot!
          – DMac
          Nov 5 '15 at 16:57












          up vote
          0
          down vote













          =COUNTIF(A:A;"comment")


          Where A:A specifies that you want to examine the whole column of A. Instead of A:A, you could also use A1:A3, which means examine A1, A2 and A3.



          EDIT:



          If you want to count the cells with comments (not with the word "comment"), I would suggest to do the following:



          =COUNT(A1:A3) - COUNTBLANK(A1:A3)





          share|improve this answer























          • i don't think the OP means has the word "comment" in a cell, but is actually a comment (little red triangle @ the top right of the cell).
            – sous2817
            Nov 4 '15 at 19:43















          up vote
          0
          down vote













          =COUNTIF(A:A;"comment")


          Where A:A specifies that you want to examine the whole column of A. Instead of A:A, you could also use A1:A3, which means examine A1, A2 and A3.



          EDIT:



          If you want to count the cells with comments (not with the word "comment"), I would suggest to do the following:



          =COUNT(A1:A3) - COUNTBLANK(A1:A3)





          share|improve this answer























          • i don't think the OP means has the word "comment" in a cell, but is actually a comment (little red triangle @ the top right of the cell).
            – sous2817
            Nov 4 '15 at 19:43













          up vote
          0
          down vote










          up vote
          0
          down vote









          =COUNTIF(A:A;"comment")


          Where A:A specifies that you want to examine the whole column of A. Instead of A:A, you could also use A1:A3, which means examine A1, A2 and A3.



          EDIT:



          If you want to count the cells with comments (not with the word "comment"), I would suggest to do the following:



          =COUNT(A1:A3) - COUNTBLANK(A1:A3)





          share|improve this answer














          =COUNTIF(A:A;"comment")


          Where A:A specifies that you want to examine the whole column of A. Instead of A:A, you could also use A1:A3, which means examine A1, A2 and A3.



          EDIT:



          If you want to count the cells with comments (not with the word "comment"), I would suggest to do the following:



          =COUNT(A1:A3) - COUNTBLANK(A1:A3)






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 4 '15 at 19:46

























          answered Nov 4 '15 at 19:40









          Pieter van der Heijden

          1467




          1467












          • i don't think the OP means has the word "comment" in a cell, but is actually a comment (little red triangle @ the top right of the cell).
            – sous2817
            Nov 4 '15 at 19:43


















          • i don't think the OP means has the word "comment" in a cell, but is actually a comment (little red triangle @ the top right of the cell).
            – sous2817
            Nov 4 '15 at 19:43
















          i don't think the OP means has the word "comment" in a cell, but is actually a comment (little red triangle @ the top right of the cell).
          – sous2817
          Nov 4 '15 at 19:43




          i don't think the OP means has the word "comment" in a cell, but is actually a comment (little red triangle @ the top right of the cell).
          – sous2817
          Nov 4 '15 at 19:43


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


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





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2fstackoverflow.com%2fquestions%2f33530472%2fhow-do-i-count-cells-with-in-a-range-in-excel-with-specific-value-that-has-a-com%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

          Costa Masnaga

          Fotorealismo

          Sidney Franklin