LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
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/

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trevor - Round Up/Down ? TQ Excel Worksheet Functions 0 July 28th 06 07:19 AM


All times are GMT +1. The time now is 06:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"