Consulting

Results 1 to 3 of 3

Thread: copying a worksheet that is hidden?

  1. #1

    copying a worksheet that is hidden?

    is it possible to copy a worksheet that is hidden into a new workbook? this code is only working if the sheet is Not Hidden.

    [vba]
    '-----Copy PrintableResults worksheet to new workbook for email submission----
    Sub CopyWorksheet()
    Dim wb As Workbook, wbName As String
    Sheets("PrintableResults").Copy
    Set wb = ActiveWorkbook
    'save full path as string variable
    wbName = ThisWorkbook.Path & "\" & Me.txtVendorName & "1.xls"
    'save workbook with that path/name
    wb.SaveAs wbName
    wb.Close
    End Sub[/vba]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Sub CopyWorksheet()
    Dim wb As Workbook, wbName As String
    Dim sh As Worksheet
    Set sh = Sheets("PrintableResults")
    sh.Visible = True
    sh.Copy
    sh.Visible = xlSheetHidden
    Set wb = ActiveWorkbook
    'save full path as string variable
    wbName = ThisWorkbook.Path & "\" & Me.txtVendorName & "1.xls"
    'save workbook with that path/name
    wb.SaveAs wbName
    wb.Close
    End Sub
    [/vba]

  3. #3
    thanks xld!

Posting Permissions

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