Count the Number of Cells Containing a Specified String in a Worksheet

Count the Number of Cells Containing a Specified String in a Worksheet

This small function counts the number of cells in a worksheet that contain a specified string and outputs a total. Suppose you set the string to = “”. The function counts the number of cells in the sheet that contain anything?you simply insert it into a module:

Option ExplicitDim max_column_number As LongDim max_row_number As LongDim counter As LongDim x As LongDim y As LongDim checkstring As StringFunction GetNotBlankCellCount(max_column_number, max_row_number, checkstring)    counter = 0    For x = 1 To max_column_number 'this is equal to the maximum number of columns you want to check        For y = 1 To max_row_number 'this is equal to the maximum number of rows you want to check                        If checkstring = "" Then                                If Not Sheet1.Cells(x, y) = "" Then 'change sheet1 to your sheet name                    counter = counter + 1                End If                            Else                If Sheet1.Cells(x, y) = checkstring Then 'change sheet1 to your sheet name                    counter = counter + 1                End If            End If                                Next y    Next x        GetNotBlankCellCount = counterEnd Function
Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across