Results 1 to 14 of 14

Multitude of random errors when cycling through workbooks in a folder to copy a range

Threaded View

LXN Multitude of random errors... 07-22-2013, 04:10 PM
AB33 Re: Multitude of random... 07-22-2013, 04:30 PM
AB33 Re: Multitude of random... 07-22-2013, 04:33 PM
LXN Re: Multitude of random... 07-22-2013, 04:43 PM
AB33 Re: Multitude of random... 07-22-2013, 04:58 PM
LXN Re: Multitude of random... 07-23-2013, 10:09 AM
LXN Re: Multitude of random... 07-23-2013, 10:18 AM
LXN Re: Multitude of random... 07-22-2013, 04:40 PM
AB33 Re: Multitude of random... 07-22-2013, 04:54 PM
AB33 Re: Multitude of random... 07-22-2013, 04:59 PM
AB33 Re: Multitude of random... 07-23-2013, 10:23 AM
LXN Re: Multitude of random... 07-23-2013, 10:30 AM
AB33 Re: Multitude of random... 07-23-2013, 10:37 AM
LXN Re: Multitude of random... 07-23-2013, 12:29 PM
  1. #1
    Registered User
    Join Date
    07-10-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    12

    Multitude of random errors when cycling through workbooks in a folder to copy a range

    I've spent all day trying to make this code work, and I have gotten dozens of errors, some of which I can fix, and some I can't.

    Option Explicit
    
    Sub OpenFiles()
    
    Dim MyFolder As String
    Dim MyFile As String
    Dim wbold As Object
    Dim wbnew As Object
    
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    Application.EnableEvents = True
    Application.Calculation = xlCalculationManual
    
    MyFolder = "C:\Users\ALRH\Desktop\Batches"
    
    MyFile = Dir(MyFolder & "\*.xl*")
    
    Set wbold = ThisWorkbook
    
    Do While MyFile <> ""
        Workbooks.Open Filename:=MyFolder & "\" & MyFile
          
        Set wbnew = ThisWorkbook
          
        Sheets(1).Select
        Range("H25:H90").Copy
        Workbooks(wbold).Sheets("Shore Tank Report").Range("I25:I90").PasteSpecial xlPasteValues
        
        Workbooks(wbnew).Range("C7:H7").Copy
        Workbooks(wbold).Cells("D7:I7").PasteSpecial xlPasteValues
                                  
       Workbooks(wbnew).Close SaveChanges:=False
                        
        On Error GoTo 0
    
        MyFile = Dir
    Loop
        
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    Application.EnableEvents = True
    Application.Calculation = xlCalculationAutomatic
        
    End Sub
    Right now I'm getting a "Type Mismatch" on the row:

    
    "Workbooks(wbold).Sheets("Shore Tank Report").Range("I25:I90").PasteSpecial xlPasteValues"
    Ask if you need more information, and thanks for any help.
    Last edited by LXN; 07-22-2013 at 04:34 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. create a compressed folder or zipped folder then copy workbooks to it.
    By Ironman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-04-2012, 03:56 PM
  2. cycling through all sub-folders in a folder
    By dyesol in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-15-2011, 10:31 AM
  3. Replies: 3
    Last Post: 02-06-2011, 05:29 AM
  4. Cycling through files in a folder
    By KateMolloy in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-28-2009, 04:18 PM
  5. Cycling through all worbooks in a folder
    By Ben in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-15-2006, 06:40 AM

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