I have a workbook containing multiple worksheets.
The sheets are named in date format dd ddd mmm. eg Wed 15 Aug. There could be many sheets named the same day but with a simple (N) at the end eg. Wed 15 Aug (3). these have been copied by worksheet.count at an early stage.
I have a Range("F3") used to find the sheet i am looking for. however i cant seem to correctly figure out how to find the last sheet in its named series. eg Wed 12 Aug (3).
the below function and relating sub works... but only finds the first in the named series eg Wed 12 Aug. I need help modifying this to find the the last in the series eg Wed 12 Aug (3). the workbook contains many different days of data.
Any help is very much appreciated.
Function SheetExist(strSheetName As String) As Boolean
Dim i As Integer
For i = 1 To Worksheets.Count
If Worksheets(i).Name = strSheetName Then
SheetExist = True
Exit Function
End If
Next i
End Function
Sub FindlastestUpdate()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim Dfind As String
Dfind = Workbooks("Inbound.Control.xlsm").Worksheets("ControlPanel").Range("F3")
Dfind = Format(Dfind, "ddd dd mmm")
If SheetExist(Dfind) Then
Workbooks("Inbound.Control.xlsm").Worksheets(Dfind).Select
Debug.Print "The Sheet Exists"
Else 'What Happends if the sheet dosnt exist
Debug.Print "The Sheet Does NOT Exists"
End If
End Sub