Thanks for the reply. Sometimes it's in the middle not very often but it's
always called "Sheet X".
Thanks
Joe
> Use this ONLY if it is always the last sheet in your workbook.
>
[quoted text clipped - 24 lines]
> > Thanks again for you help
> > Joe
Does "X" represent an unknown number, or is it actually "SheetX" or "Sheet
X"?
If that is the case, then I would think you could just adjust the code to
include the specific sheet name.
Sheets("SheetX").Delete
If "SheetX" is not the actual sheet name and "X" just represents the
automatic sheet number when a sheet is inserted, then we'll have to come up
with an alternative. If that is the case, then how many sheets could there
be in this workbook? Would the X number ever be double digits? Would any
other sheet names end in a number (example, a sheet named say,
"Test4"...basically a sheet that does not begin with the word "Sheet" but
still ends in a number).
Regards,
Paul
> Thanks for the reply. Sometimes it's in the middle not very often but it's
> always called "Sheet X".
[quoted text clipped - 34 lines]
>> > Thanks again for you help
>> > Joe
Joe Gieder - 21 May 2008 16:52 GMT
X is an unknown.
> Does "X" represent an unknown number, or is it actually "SheetX" or "Sheet
> X"?
[quoted text clipped - 52 lines]
> >> > Thanks again for you help
> >> > Joe
Joe Gieder - 21 May 2008 16:56 GMT
Sorry. I did not read the whole question. X is the automatic sheet number and
it should not be double digits. I currently have six named sheets but I will
be adding several mor to consolidate workbooks. Yes, other sheets do end in a
number because they're purchase order numbers.
Thanks for your help
Joe
> Does "X" represent an unknown number, or is it actually "SheetX" or "Sheet
> X"?
[quoted text clipped - 52 lines]
> >> > Thanks again for you help
> >> > Joe
Joe Gieder - 21 May 2008 17:00 GMT
I found this code:
Sub DeleteSheets()
Dim wks As Worksheet
On Error GoTo ErrorHandler
Application.DisplayAlerts = False
For Each wks In Worksheets
If InStrUCase(wks.Name, "Bill") > 0 Then wks.Delete
Next wks
ErrorHandler:
Application.DisplayAlerts = True
End Sub
And replaced Bill with Sheet but it did not work, I got an error saying "Sub
or Function not defined" and I'm not sure what it's telling me.
Joe
> Does "X" represent an unknown number, or is it actually "SheetX" or "Sheet
> X"?
[quoted text clipped - 52 lines]
> >> > Thanks again for you help
> >> > Joe
Bernie Deitrick - 21 May 2008 17:42 GMT
Joe,
It is telling you that
InStrUCase
is a custom function that you haven't included in your module. See my other response for the
commonly accepted best technique for doing what you want to do.
HTH,
Bernie
MS Excel MVP
>I found this code:
> Sub DeleteSheets()
[quoted text clipped - 71 lines]
>> >> > Thanks again for you help
>> >> > Joe