Removing Macro from Saved file


Posted by Kev on January 22, 2002 6:06 AM

Hello.

I have a problem, I am testing my macro and I am saving the file with the same name as the source file but under a different directory.

When I open the saved file it starts the Macro.
I would like to write a code that will say in the auto open that id there are sheets already present then the macro should not start. I believe there is a command called:

if sheetexists

if anyone knows this command please could you give me an example as to how I can use it.

Thanks.



Posted by Joe Was on January 22, 2002 7:09 AM

Try this for your test. I never heard of sheetsexists bur testing for sheet name will do the same thing.

Sub mysheet()
For Each ws In Worksheets
If ws.Name = "" Then _
MsgBox "none" Else
MsgBox ws.Name
Next ws

End Sub

To use the just add your code inplace of the MsgBox codes above.

Also, the sheet function to return the number of sheets in a workbook is:

=Info("numfile")

Hope this helps? JSW