P
Pam
Hello:
I am using a marco to copy two sheet into a workbook from an existing
sheet in same workbook.
I want the user to have the ability to run the marco more than once
which updates the sheet by going to the database, there fore I don't
want the sheets copied more than once..
I check to see if sheet exist, if not I copy it. It works with the
fisrst sheet, but
when I do the test on the second sheet I get subscript out of range.
When I run the macro a second time it works. Its not consistant
What am I doing wrong the logic is the same?
SheetExists = False
On Error GoTo NoSuchSheet
If Len(Sheets("CCB_Host_Analysis").Name) > 0 Then
SheetExists = True
MsgBox ("Sheet already Exist")
End If
NoSuchSheet:
If SheetExists = False Then
Sheets("Sheet1").Copy Before:=Sheets(1)
Sheets("Sheet1 (2)").Select
Sheets("Sheet1 (2)").Name = "LogicalSheet"
Range("C13").Select
MsgBox ("Adding Sheet")
End If
SheetExists = False
On Error GoTo Sheet
If Len(Sheets("3G_Triage_Analysis").Name) > 0 Then
SheetExists = True
MsgBox ("Sheet2 already Exist")
End If
Sheet:
If Sheet2Exists = False Then
Sheets("Sheet1").Copy Before:=Sheets(2)
'Sheets("Sheet1 (2)").Select
Sheets("Sheet1 (2)").Name = "Testsheet"
Range("C13").Select
MsgBox ("No sheet2 exist Adding sheet")
End If
Thank You
Pam
I am using a marco to copy two sheet into a workbook from an existing
sheet in same workbook.
I want the user to have the ability to run the marco more than once
which updates the sheet by going to the database, there fore I don't
want the sheets copied more than once..
I check to see if sheet exist, if not I copy it. It works with the
fisrst sheet, but
when I do the test on the second sheet I get subscript out of range.
When I run the macro a second time it works. Its not consistant
What am I doing wrong the logic is the same?
SheetExists = False
On Error GoTo NoSuchSheet
If Len(Sheets("CCB_Host_Analysis").Name) > 0 Then
SheetExists = True
MsgBox ("Sheet already Exist")
End If
NoSuchSheet:
If SheetExists = False Then
Sheets("Sheet1").Copy Before:=Sheets(1)
Sheets("Sheet1 (2)").Select
Sheets("Sheet1 (2)").Name = "LogicalSheet"
Range("C13").Select
MsgBox ("Adding Sheet")
End If
SheetExists = False
On Error GoTo Sheet
If Len(Sheets("3G_Triage_Analysis").Name) > 0 Then
SheetExists = True
MsgBox ("Sheet2 already Exist")
End If
Sheet:
If Sheet2Exists = False Then
Sheets("Sheet1").Copy Before:=Sheets(2)
'Sheets("Sheet1 (2)").Select
Sheets("Sheet1 (2)").Name = "Testsheet"
Range("C13").Select
MsgBox ("No sheet2 exist Adding sheet")
End If
Thank You
Pam