ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro Help - check existing tabs (https://www.excelbanter.com/excel-programming/305149-macro-help-check-existing-tabs.html)

Macro Help[_2_]

Macro Help - check existing tabs
 
I have a macro that takes data from an existing tab,
creates a new tab called "Final", and does some
formatting stuff with it. An improvement I want to make
is to have the macro check the workbook at the beginning
to see if it already has an existing "Final" tab, and if
so, prompt the user whether to delete the existing tab or
quit the macro. How do I make this work?

Thank you

Bob Phillips[_7_]

Macro Help - check existing tabs
 
Dim oSheet As Worksheet

On Error Resume Next
Set oSheet = Worksheets("Sheet1")
On Error GoTo 0
If oSheet Is Nothing Then
Worksheets.Add.Name = "Sheet1"
End If

--
HTH

-------

Bob Phillips
"Macro Help" wrote in message
...
I have a macro that takes data from an existing tab,
creates a new tab called "Final", and does some
formatting stuff with it. An improvement I want to make
is to have the macro check the workbook at the beginning
to see if it already has an existing "Final" tab, and if
so, prompt the user whether to delete the existing tab or
quit the macro. How do I make this work?

Thank you





All times are GMT +1. The time now is 06:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com