Dear All,
I am getting an application defined or object defined error on the line in bold below. Can anybody shed any light ? thanks
Kaps
The function does_sheet_exist is defined as:-
I am getting an application defined or object defined error on the line in bold below. Can anybody shed any light ? thanks
Kaps
Rich (BB code):
If does_sheet_exist(trustworkbook, "QIPP") = True Then
MsgBox "QIPP " & i & " " & trust_code
trustworkbook.Sheets("QIPP").Name = trust_code
quipp_template_file.Sheets.Add before:=quipp_template_file.Sheets("end")
ActiveSheet.Name = trust_code
trustworkbook.Sheets(trust_code).Range("a1:az300").Copy quipp_template_file.Sheets(trust_code).Range("a1")
End If
Rich (BB code):
Public Function does_sheet_exist(file_to_search As Workbook, sheet_to_find) As Boolean
does_sheet_exist = False
Dim i As Long
Dim no_of_sheets As Long
no_of_sheets = file_to_search.Sheets.Count
For i = 1 To no_of_sheets
If file_to_search.Sheets(i).Name = sheet_to_find Then
does_sheet_exist = True
Exit For
End If
Next
End Function