Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

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)

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
   End If
  End If
Next ws
  • No labels