VBA Excel Find in 2 Column with Count

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rosshughson
    New Member
    • May 2010
    • 9

    #1

    VBA Excel Find in 2 Column with Count

    I'm lost here. I need to count the number or rows that contain different text. In one column, it will be an exact match to the cell. In the other column, the text will be contained within the cell. I'm guessing that I want to create a function that will accept the name of the worksheet and the two search strings and return the count. Any help would be appreciated.
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    Originally posted by rosshughson
    I'm lost here. I need to count the number or rows that contain different text. In one column, it will be an exact match to the cell. In the other column, the text will be contained within the cell. I'm guessing that I want to create a function that will accept the name of the worksheet and the two search strings and return the count. Any help would be appreciated.
    Is it possible to give an example with the original data and what you want to find?
    Or better: attach a sheet to your mail with the start data and the expected results.

    Comment

    • rosshughson
      New Member
      • May 2010
      • 9

      #3
      VBA Excel Finds with Count

      I'm attaching a sample worksheet. The code I need will find an exact match in column "E", for example "SR032526" and search the text in column "D" for a specified string - perhaps "SERVICES". With these examples, I would need a function that returned 2, which is the number of rows (row 3 and row 5) that meet those criteria. Thanks.
      Attached Files

      Comment

      • rosshughson
        New Member
        • May 2010
        • 9

        #4
        Sorry - the attachment isn't formatted very well. I don't know how to get around this.

        Comment

        • Guido Geurs
          Recognized Expert Contributor
          • Oct 2009
          • 767

          #5
          Originally posted by rosshughson
          Sorry - the attachment isn't formatted very well. I don't know how to get around this.
          Is it not possible to attach just an excel file (zipped) with a sheet and some data?
          I have try-ed to import your data TXT file but the contents of the cells are not clear to me.
          Last edited by Niheel; May 27 '10, 08:31 PM. Reason: removed dear and br, makes it harder to read the discussions

          Comment

          • rosshughson
            New Member
            • May 2010
            • 9

            #6
            VBA Excel Find with Count

            OK. Let's try this again. I'm attaching a zipped file.
            Attached Files

            Comment

            • Guido Geurs
              Recognized Expert Contributor
              • Oct 2009
              • 767

              #7
              Attached is a zipped XLS with the macro "Find_Rows" .
              Run it and it will give you a msgbox with "2".

              I hope this will help you.
              Attached Files
              Last edited by Niheel; May 27 '10, 08:31 PM. Reason: removed dear and br, makes it harder to read the discussions

              Comment

              • rosshughson
                New Member
                • May 2010
                • 9

                #8
                VBA Excel Find with Count

                Thanks! This is just what I need. I'll tweak it a bit to make it a reusable function and I should be good to go. Thanks for your help.

                Comment

                Working...