Results 1 to 18 of 18

Thread: Coping with duplicates being created by code splitting worksheets into separate files

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #17
    snb
    Guest
    I'd use:

    Sub M_snb()
       c00="G:\OF\"
    
       sn = Filter(Split(CreateObject("wscript.shell").exec("cmd /c dir """ & c00 &"*.xls*"" /b/s").stdout.readall, vbCrLf), ".")
       
       For j = 0 To UBound(sn)
         With GetObject(sn(j))
           For Each sh In .Sheets
              sh.Copy
              With ActiveWorkbook
                .SaveAs Replace(Replace(sn(j), "\", "_"), ".xls", "_" & sh.Name & "_"), 51
                .Close 0
              End With
            Next
            .Close 0
          End With
        Next
    End Sub
    Last edited by snb; 06-08-2015 at 04:00 AM.

Posting Permissions

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