|
-
Sep 16th, 2003, 12:59 PM
#1
Thread Starter
Junior Member
Checking for Sheets in Excel 97
Hi all,
Hopefully this question won't be as dolt-ish as the last one....
OK, I am writing a series of macros to run a rather large series of reports. For one of these reports, I must take data from a set worksheet called "Sort" and paste data into a worksheet that has a different name every day. The name, however, is uniform in format, and reads "9.12 Day 13" for September 12, 13 days late, and "9.13 Day 14" for September 13, 14 days late, etc.
The problem really is that the Days late is not predictable months in advance. So, what I'm wondering is whether or not there is a way to chech whether worksheets exist in a workbook, something like
If 9.12 Day 14 exists, return True, if true, paste in that worksheet (but, of course, in VB)
I'm using Excel 97, so any help on this would be greatly appreciated.
Thanks,
Joshua Wise
-
Sep 17th, 2003, 04:49 PM
#2
Member
Hello,
Here is the code to check if the name of worksheet already exitsts.
You just have to do a few modifiacations to use it for your purpose.
Private Sub CommandButton1_Click()
Dim strSheetName As String
Dim mySheet As Worksheet
Dim blnNameFound As Boolean
blnNameFound = False
strSheetName = "9.12 Day 14"
For Each mySheet In Worksheets
If mySheet.Name = "9.12 Day 13" Then
blnNameFound = True
End If
Next mySheet
If blnNameFound = True Then
MsgBox "The worksheet with the name " & strSheetName & " already exists."
End If
End Sub
Greets,
J@b@r
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|