Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can I look for a sheet in a wkbk and run a macro if not there
I need to look for a sheet name within a workbook and run a macro if the
sheet name does not exist. any suggestions? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can I look for a sheet in a wkbk and run a macro if not there
I have used a form of the following:
On error goto macrorun Sheets("Sheetname").Activate macrorun: call your macro -- Best wishes, Jim "jkt" wrote: I need to look for a sheet name within a workbook and run a macro if the sheet name does not exist. any suggestions? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can I look for a sheet in a wkbk and run a macro if not there
I forgot to mention that if there are worksheets that are hidden, you would
need to add: On error resume next Sheets("sheetname").visible=true on error goto 0 Then the rest from the previous response. -- Best wishes, Jim "jkt" wrote: I need to look for a sheet name within a workbook and run a macro if the sheet name does not exist. any suggestions? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can I look for a sheet in a wkbk and run a macro if not th
Using this code may cause you a problem as it moves from normal execution to
exectuion within an errorhandler (there is no resume statement to exit the error handler). This means that if any other error are generated they can not be handled. You are better off with code like this... sub do whatever() if sheetexists("Sheet1") = false then call MyMacro end if exit sub Public Function SheetExists(SName As String, _ Optional ByVal Wb As Workbook) As Boolean 'Chip Pearson On Error Resume Next If Wb Is Nothing Then Set Wb = ThisWorkbook SheetExists = CBool(Len(Wb.Sheets(SName).Name)) End Function -- HTH... Jim Thomlinson "Jim Jackson" wrote: I have used a form of the following: On error goto macrorun Sheets("Sheetname").Activate macrorun: call your macro -- Best wishes, Jim "jkt" wrote: I need to look for a sheet name within a workbook and run a macro if the sheet name does not exist. any suggestions? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copying cell info from one sheet to another in the same wkbk | Excel Discussion (Misc queries) | |||
Large wkbk won't recalc after moving sheet | Excel Discussion (Misc queries) | |||
How do I replicate an area of a SS onto another sheet in same wkbk | Excel Discussion (Misc queries) | |||
Move a sheet to last sheet of wkbk | Excel Programming | |||
Copy paste WkBk/sheet 1 to multiple wkbks/sheets | Excel Programming |