https://stackoverflow.com/questions/37882735/finding-part-of-a-sheet-name
Public Function FindWorksheet(PartOfWSName As String) As Worksheet For Each ws In ActiveWorkbook.Sheets If InStr(ws.Name, PartOfWSName) > 0 Then Debug.Print ws.Name Set FindWorksheet = ws Exit For End If Next ws End Function
Sub TestingSpot_Sub() Dim PartOfWSName As String PartOfWSName = "Egas" Dim ws As Worksheet Set ws = FindWorksheet(PartOfWSName) ws.Activate End Sub
Let searchTerm = "Hello World" For Each ws In ActiveWorkbook.Sheets If Left(ws.Name, Len(searchTerm)) = searchTerm Then If Right(ws.Name, Len(searchTerm)) = searchTerm Then End If End If Next ws
Dim DateStr As String DateStr = Format(Date, "DD-MM-YY") Yesterday = Format(DateAdd("d", -1, CDate(DateStr)), "DD-MM-YY") YtdStr = Format(Yesterday, "DD-MM-YY") Dim FourDaysOld As Date, FourDaysOldStr As String FourDaysOld = Format(DateAdd("d", -4, CDate(DateStr)), "DD-MM-YY") For Each ws In ActiveWorkbook.Sheets wsLeft = Left(ws.Name, (Len(FourDaysOld))) wsLeftFormat = Format(wsLeft, "DD-MM-YY") If IsDate(wsLeft) Then If DateDiff("d", wsLeftFormat, FourDaysOld) > 0 Then Debug.Print ws.Name ws.Delete End If End If Next ws