Results 1 to 1 of 1

Paste into cells in new workbook.

Threaded View

  1. #1
    Forum Contributor
    Join Date
    02-23-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    133

    Paste into cells in new workbook.

    First of all i am sorry if this is a re-post to an open thread. I dont see my post for some reasons and since i did not get any reply, i guess it never got posted.

    Anyways, hello..

    I have a code ready which used to work with other workbook. I have attached 2 workbooks and this is my code.


    Sub CardBG()
    ' hay Macro
    '
    ' Keyboard Shortcut: Ctrl+h
    '
           
        Dim f As String
        Dim ii As String
        Dim r As String
        Dim ri As String
        Dim path As String
        
        'Turn screen updating off. You won't see the client file being updated.
    Application.ScreenUpdating = False
    
        
    
       
       
       ' path to your folder
        path = "D:\excelreport\CardBG\"
        
        i = 1
        x = Cells(i + 1, 1)
        
        Do While x <> Empty
        
        ii = i
        f = ii + ".xlsx"
       
          
        Workbooks.Open Filename:=path & "CARDBG.xlsx"
        Windows("CARDBG.xlsx").Activate
        ActiveWorkbook.SaveCopyAs Filename:=path & f
        Workbooks.Open Filename:=path & f
        
       
        ri = i + 1
        
        Windows("CARDBG.xlsm").Activate
        
        
        
       r = "B" & ri
        Range(r).Select
        Selection.Copy
        Windows(f).Activate
        Range("C6").PasteSpecial xlPasteValues
        
        
        
        r = "C" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("C7").PasteSpecial xlPasteValues
        
        
        
        r = "D" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("G6").PasteSpecial xlPasteValues
        
        
        
        r = "E" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("G7").PasteSpecial xlPasteValues
        
        
        
        r = "F" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("D8").PasteSpecial xlPasteValues
        
        
        
         r = "G" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("C9").PasteSpecial xlPasteValues
        
        
        
         r = "I" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("C15").PasteSpecial xlPasteValues
        
        
        
        r = "J" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("C16").PasteSpecial xlPasteValues
        
        
        
        r = "K" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("G15").PasteSpecial xlPasteValues
        
        
        
        r = "L" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("G16").PasteSpecial xlPasteValues
        
        
        
         r = "M" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("D17").PasteSpecial xlPasteValues
        
        
        
          
         r = "N" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("C18").PasteSpecial xlPasteValues
        
        
        
        r = "P" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("C24").PasteSpecial xlPasteValues
        
        
        
        r = "Q" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("C25").PasteSpecial xlPasteValues
        
        
        
        r = "R" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("G24").PasteSpecial xlPasteValues
        
        
        
        r = "S" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("G25").PasteSpecial xlPasteValues
        
        
        
            
        r = "T" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("D26").PasteSpecial xlPasteValues
        
        
        
         r = "U" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("C27").PasteSpecial xlPasteValues
        
        
        
        r = "W" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("C33").PasteSpecial xlPasteValues
        
        
        
        r = "X" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("C34").PasteSpecial xlPasteValues
        
        
        
        r = "Y" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("G33").PasteSpecial xlPasteValues
        
        
        
        r = "Z" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("G34").PasteSpecial xlPasteValues
        
        
        
            
        r = "AA" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("D35").PasteSpecial xlPasteValues
        
        
        
        
        r = "AB" & ri
        Range(r).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows(f).Activate
        Range("C36").PasteSpecial xlPasteValues
        
            
       ActiveWorkbook.Save
       ActiveWorkbook.Close
       
        Windows("CARDBG.xlsx").Activate
        ActiveWorkbook.Save
        ActiveWorkbook.Close
       
        
     
        Windows("CARDBG.xlsm").Activate
        i = i + 1
        x = Cells(i + 1, 1)
        Loop
        
        
           
        'Turn screen updating ON. You won't see the client file being updated.
    Application.ScreenUpdating = True
        
    End Sub
    Code does: Make a copy of sample file ---> rename it as 1.xlsx 2.xlsx..and so on ---> Copy cells into those files---> save file---> loop.

    This code works fine with other workbooks but i am not able to run the code here and getting error. Debug shows stuck at G6.
    What am i missing?

    TIA
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Copy Filter Data and paste it on another workbook with special cells(Only Visible Cells)
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-13-2014, 07:59 AM
  2. [SOLVED] Copy Specific Cells Across all worksheets in a Workbook and Paste Into single New Workbook
    By thunt13 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-14-2013, 10:43 AM
  3. [SOLVED] Need Macro to copy and paste certain cells to another workbook
    By Dnakr in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-05-2013, 11:32 AM
  4. Search for a value in closed workbook and paste adjacent cells to open workbook
    By jmapark91 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-22-2013, 10:54 AM
  5. Replies: 2
    Last Post: 10-07-2012, 12:42 PM
  6. Copy and paste non consecutive cells and paste consecutively in another workbook
    By macquhele in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-12-2011, 02:36 PM
  7. Copy & Paste Cells to another workbook
    By Barking_Mad in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-30-2010, 07:47 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