+ Reply to Thread
Results 1 to 2 of 2

Code to turn this code into a loop doing muliple copies

Hybrid View

  1. #1
    Registered User
    Join Date
    02-14-2013
    Location
    Dallas TX
    MS-Off Ver
    Excel 2007
    Posts
    12

    Code to turn this code into a loop doing muliple copies

    I need help converting this code to do mulitple copies using the Copy Before function. Also a next function argumenting files that have a worksheet nameD "COMPILED".

    Sub Stat_Compiling()
    Dim Thisworkbook As Workbook
    Dim Compiledwkst As Worksheet
    Dim Templateworkbook As Workbook
    Dim NewFN As Variant
    
    Application.ScreenUpdating = True
    
    NewFN = Application.GetOpenFilename(FileFilter:="Excel Files (*.xlsx), *.xlsx", Title:="Please select a file", MultiSelect:=False)
    
    If NewFN = False Then
    MsgBox "Stopping because you did not select a file"
              Exit Sub
        Else
            Set Thisworkbook = Workbooks.Open(Filename:=NewFN)
    End If
    Set Templateworkbook = Workbooks.Open("\\tsscitrix\Heat\Kim Comer\Phone System Reports\Template\Template.xlsx")
    Templateworkbook.Sheets("COMPILED").Copy Before:=Thisworkbook.Sheets("1040")
    Range("A1").Select
        Cells.Replace What:="[Template.xlsx]", Replacement:="", LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False
    Thisworkbook.Save
    Templateworkbook.Close
    Thisworkbook.Close
    Application.ScreenUpdating = True
    
    MsgBox "Done"
     
    End Sub

  2. #2
    Registered User
    Join Date
    02-14-2013
    Location
    Dallas TX
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Code to turn this code into a loop doing muliple copies

    multiple workbooks I mean, I would like to select multiple files from the application.getopenfilename fuction and then run each file through a loop

+ Reply to Thread

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