Results 1 to 7 of 7

Error Worksheet Exists - need code to continue to next name if it does

Threaded View

  1. #1
    Registered User
    Join Date
    10-13-2010
    Location
    Colorado Springs, CO
    MS-Off Ver
    Excel 2010
    Posts
    55

    Error Worksheet Exists - need code to continue to next name if it does

    Hi,

    I have the following code that is used to generate worksheets automatically from a listing of names on the "Master Provider List". It works perfectly, but I have found that sometimes I need to add more names to the list. I need the code to look at the list and if the worksheet related to the name already exists, continue on to the next name and create the worksheet. I have never trapped an error before, so not sure how to add that to my code.
    Private Sub Create_PList_Click()
    'creates the provider's sheets, names the sheet, and enters sheet name in c4 of the new sheet
    Dim i As Integer
        Dim ws As Worksheet
        Dim Sh As Worksheet
        Set ws = Sheets("Audit Temp")
        Set Sh = Sheets("Master Provider List")
        
        Application.ScreenUpdating = 0
        Sheets("Audit Temp").Visible = True
        For i = 3 To Range("A" & Rows.Count).End(xlUp).Row
            Sheets("Audit Temp").Copy After:=ws
            ActiveSheet.Name = Sh.Range("A" & i).Value
            ActiveSheet.Cells(4, 3) = Sh.Cells(i, 1)
        Next i
        Sheets("Audit Temp").Visible = False
        Sheets("Master Provider List").Activate
    
    End Sub

    Thanks so much in advance

    C
    Last edited by missit; 03-28-2014 at 06:08 PM. Reason: Fixed so code shows correctly.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro code to continue iterating if error.
    By sid9221 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-23-2013, 03:39 PM
  2. [SOLVED] IF Exists or on Error Then - Skip Code- How to write code?
    By Jack7774 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-22-2013, 06:45 PM
  3. [SOLVED] changing cell on active sheet does not cause code to continue - No error codes either
    By SoteriaLive in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-01-2012, 11:21 AM
  4. VBA Code to continue in Update Links error message
    By dcgrove in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-21-2011, 03:53 PM
  5. Code error, highlight error, continue to RUN
    By JohnSeito in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-07-2008, 01:29 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1