Results 1 to 2 of 2

Thread: Checking for Sheets in Excel 97

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2003
    Location
    Mt. Holly, NJ
    Posts
    31

    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

  2. #2
    Member
    Join Date
    Feb 2003
    Posts
    40
    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
  •  



Click Here to Expand Forum to Full Width