+ Reply to Thread
Results 1 to 3 of 3

loop copy & paste visible Ws only without hidden sheets to new Wb

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-17-2013
    Location
    USA, IL
    MS-Off Ver
    Excel 2010
    Posts
    121

    loop copy & paste visible Ws only without hidden sheets to new Wb

    Hi

    I was wondering if I can get assistance with a vba that copies visible worksheets only from a number of files in a folder into a new workbook. The issue is each of the files in the folder have hidden worksheets and I do not want the hidden worksheets just the visible sheets. And hopefully the vba can loop through all the files and copy the visible sheets into my workbook from which I ran the vba.
    I appreciate your help and advice.

    thanks in advance

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,012

    Re: loop copy & paste visible Ws only without hidden sheets to new Wb

    Select the files of interest when prompted.

    Sub PullInVisibleSheetsFromSelectedFiles()
        Dim FileArray As Variant
        Dim wkBk As Workbook
        Dim WS As Worksheet
        Dim i As Integer
        
        FileArray = Application.GetOpenFilename(MultiSelect:=True)
    
        If IsArray(FileArray) Then
            For i = LBound(FileArray) To UBound(FileArray)
                Set wkBk = Workbooks.Open(FileArray(i))
                For Each WS In wkBk.Worksheets
                    If WS.Visible Then
                        WS.Copy after:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)
                    End If
                Next WS
                wkBk.Close False
            Next i
        End If
    End Sub
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Contributor
    Join Date
    03-17-2013
    Location
    USA, IL
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: loop copy & paste visible Ws only without hidden sheets to new Wb

    Wow very very Impressive!!!
    Bernie Thank You very much. I have been struggling with this for 2 days and I truly appreciate your time and assistance.

    Thank you.

    Pi*

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy a table hidden & visible row data & paste all data
    By How How in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-18-2015, 01:43 PM
  2. Copy and Paste VISIBLE rows not hidden
    By booney440 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-09-2015, 08:03 AM
  3. vba to copy a picture from a hidden sheet and paste in visible sheet?
    By thecdnmole in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-30-2015, 10:21 AM
  4. [SOLVED] Format all cells in all sheets to Protection Hidden on visible and hidden tabs
    By DeRo22 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-28-2014, 03:17 PM
  5. Replies: 4
    Last Post: 01-06-2014, 02:14 AM
  6. Copy And Paste visible Sheets and from second worksheet
    By tantcu in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-20-2013, 03:59 AM
  7. macro copy paste on protect sheets and hidden within the same workbook
    By Birnen in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-30-2010, 02:18 PM

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