FindSheet

Finds a sheet in a workbook, if no workbook name passed, it will use ThisWorkbook.
Returns true if found, or false if not

Function FindSheet(SheetName, Optional ThisWB = "") As Boolean
 ' Searches for a sheet in a workbook
 ' Can also be used as User-Defined-Function
 If ThisWB = "" Then ThisWB = ThisWorkbook.Name
 FindSheet = False
 If SheetName = "" Then Exit Function
 For I = 1 To Workbooks(ThisWB).Sheets.Count
  If UCase(SheetName) = UCase(Workbooks(ThisWB).Sheets(I).Name) Then
   FindSheet = True
   Exit Function
  End If
 Next I
End Function

SheetName, Optional ThisWB

Views 2061 Downloads 674

'Sheets', 'tabs', 'Excel', 'Sheet', 'find', 'search', 'workbook'

ANmarAmdeen
520
Components VBA-Excel
Revisions

v2.0