0

I'm trying to figure out how to check which tabs contain a certain word and to count these instances.

I have it set up currently that when a "client" is lost, their data tab is renamed to contain "ARCHIVED". I'm trying to do a count to see how many clients have been lost, so was ideally hoping I'd be able to do a sum of the tabs containing "ARCHIVED" but I'm uncertain how to go about this.

2
  • 2
    Please share the details of the code you tried and describe the issue you are encountering. Commented Feb 26 at 17:47
  • @Aimee Allow me a remark: Stack Overflow has the option to upvote helpful answers and if there is an answer that you feel answers your question (best) you can accept it by ticking the green checkmark on its left. The sites tour tells you a bit more about that. "Someone answers" Commented Feb 27 at 18:07

1 Answer 1

1

Loop through the sheets and validate their names using InStr.

Sub Demo()
    Dim Sht As Object
    Dim iCount As Long
    For Each Sht In ThisWorkbook.Sheets
        If InStr(1, Sht.Name, "ARCHIVED", vbTextCompare) > 0 Then
            iCount = iCount + 1
        End If
    Next
    MsgBox "Found " & iCount & " sheets"
End Sub
Sign up to request clarification or add additional context in comments.

3 Comments

My reading from OP is that "data tab" would refer to a worksheet specifically, while Sheets would include chart sheets. But who uses those nowadays :-)
Thanks this was perfect! I needed the result to populate in a table so I omitted the MsgBox and popped the range.value in there instead. Thanks :)
@BigBen Maybe you are right. But who knows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.