sonicdemonic
06-16-2008, 02:03 PM
Ok, my code copies an existing worksheet. Where the code places it is depending on whether other sheets exist.
Now to test if a worksheet exists I have been using:
Set wSheet = Sheets("Log " & Right(strBoxName, 2))
If Not wSheet Is Nothing Then
'If the sheet log 7 exists then copy.after
End If
Since I have this code checking if many sheets exist I tried to change the format to the following:
If Not Sheets("Log 7") Is Nothing Then
'If the sheet log 7 exists then copy.after
End If
Now that does not work. It returns true reguardless of whether Log 7 exists or not.
I have 5 different worksheets that the user and create more version of and the user can make up to 10 copies of each worksheet. I want the worksheet to be succeeding. The versions that get copied are hidden worksheets that the user does not have acccess to. I tried to have excel copy after the hidden sheet but that doesnt work, somehow it doesnt keep its placing after items are added to the workbook.
Currently the only way I can figure to code this is to set variables for each worksheet I need to test for. Which I can do. I would like to code it so that if will be easier to change in the future.
So my questions are:
Do I have to assign the sheet name I am testing for to a worksheet variable?
Or
I there a better way to to code what I am trying to accomplish?
Now to test if a worksheet exists I have been using:
Set wSheet = Sheets("Log " & Right(strBoxName, 2))
If Not wSheet Is Nothing Then
'If the sheet log 7 exists then copy.after
End If
Since I have this code checking if many sheets exist I tried to change the format to the following:
If Not Sheets("Log 7") Is Nothing Then
'If the sheet log 7 exists then copy.after
End If
Now that does not work. It returns true reguardless of whether Log 7 exists or not.
I have 5 different worksheets that the user and create more version of and the user can make up to 10 copies of each worksheet. I want the worksheet to be succeeding. The versions that get copied are hidden worksheets that the user does not have acccess to. I tried to have excel copy after the hidden sheet but that doesnt work, somehow it doesnt keep its placing after items are added to the workbook.
Currently the only way I can figure to code this is to set variables for each worksheet I need to test for. Which I can do. I would like to code it so that if will be easier to change in the future.
So my questions are:
Do I have to assign the sheet name I am testing for to a worksheet variable?
Or
I there a better way to to code what I am trying to accomplish?