I want to share this info with everyone!!! It could be useful


Posted by Kev Tweddle on January 24, 2002 6:12 AM

To everyone!!

I have a makro that reads a large list of data from a text file and then I filter out certain data and display the filtered data on another sheet. From this data I create a 3D Pie chart whose values are shown in percentages (bloody slow when makro executed, probably through data filtering) then I saved my file under a different directory but as the same name (this was testing ma makro). When I opened the file the Makro sprang to life and that is not what I wanted. So how do I get around this problem:

My makro basically was a form with choices as to what sort of data would be loaded, there two different types. For example my makro has a choice of loading data with files in MB and the other shows how much data is free on users Hard Drives.

Read the code through, think about it, it really is helpful

Private Function SheetExists(Table As String) As Boolean
Dim hidden As Variant
On Error GoTo errorhandler
hidden = Sheets(Table).Visible
SheetExists = True
Exit Function

errorhandler:
SheetExists = False

End Function

Public Sub auto_open()
If SheetExists("<Name of worksheet>") Then
Exit Sub
ElseIf SheetExists("<If you have another worksheets name from the other data>") Then
Exit Sub
Else
Procedure name of start of Makro (Usually Module 1)
End If
End Sub

What use is this code you ask?

Imagine you start the makro and you want to save it but accidentally you save it under a different directory as the same filename this will remove the problem of the makro always starting.

What about if someone clicks the save button, it will overwrite the makro file and then you’re buggered. Solution (if you have Winnt 4.0 or Win2000 set the rights so that only you have full access to the file whereas the others can only read it.


Posted by Steve on January 24, 2002 6:42 AM

Ok great. Just a note, if it is really running unbearably slow you should turn off screen updating while it runs and make sure to turn it back on when the macro is done.

Application.ScreenUpdating

Steve




Posted by Kev Tweddle on January 24, 2002 7:16 AM

I've tried that already but it was no good, I've tried a lot of other ways but well in the end it's still slow. Bugger!!