View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Calypsoblur[_3_] Calypsoblur[_3_] is offline
external usenet poster
 
Posts: 1
Default Thanks Trevor Shuttleworth


I was able to get it working for now. Tomorrow I will test its stability
by opening and closing it a few (hundred? :) and running several
numbers through it each time. My problem was two fold. One I couldn't
open sheets with that number. When my variable is a number, Excel tries
to open not sheet "number" but rather sheet number. The difference
being the name and the number of the sheet. So, I copied in your change
and also added one more variable. I changed my old public variable to a
long, and the new one a string. Set the string equal to the public
long, and try to open the string. Worked like a charm! New code listed
below
Craig Robson


'Checks for sheet PumpSheet and creates it if it does
'not exist.

Public Sub NewSheet()
Dim PumpSheetNumber As String
'If error is created, then goes to label CreatSheet
On Error Resume Next

PumpSheetNumber = PumpNumber

'Tries to activate the sheet PumpSheet
Sheets(PumpSheetNumber).Activate

'Creates the sheet PumpSheet
If Err < 0 Then
Set xSheet =
Worksheets.Add(after:=Worksheets(Worksheets.Count) )
With xSheet
Name = PumpNumber
'Enters header information
Range("A1") = "Number"
Range("B1") = "Hours"
Range("C1") = "Date"
Range("D1") = "Lugs"
End With

End If


'Restores normal error handling
On Error GoTo 0

End Sub


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/