Results 1 to 5 of 5

Error Handling on Copy Sheets

Threaded View

ker9 Error Handling on Copy Sheets 12-01-2011, 10:22 AM
Kelshaer Re: Error Handling on Copy... 12-01-2011, 11:14 AM
Kelshaer Re: Error Handling on Copy... 12-01-2011, 11:15 AM
ker9 Re: Error Handling on Copy... 12-03-2011, 11:30 AM
Kelshaer Re: Error Handling on Copy... 12-06-2011, 01:26 PM
  1. #1
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2010
    Posts
    278

    Error Handling on Copy Sheets

    Hi, The code below runs the first If statement even if sheets are visible. How do I check if no sheets are visible to make this work? (If I remove the first If statement, the remainder works as it should, but there is no copy made if there are no visible sheets and no error message.)

    Dim ws As Worksheet
    For Each ws In Worksheets
        
        If ws.Name <> "Select" And ws.Visible = False Then
            MsgBox "No worksheets available to copy - please make selections using the Open Selection Form button."
            Exit Sub
            
            ElseIf ws.Name <> "Select" And ws.Visible = True Then
                ws.Copy
                    Cells.Select
                    Selection.Rows.AutoFit
                    Rows(1).RowHeight = 65
                    Range("A1").Select
            End If
        Next
    Last edited by ker9; 12-03-2011 at 11:30 AM.

Thread Information

Users Browsing this Thread

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

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