Results 1 to 5 of 5

Copy Pasting data from one excel workbook to another using vba

Threaded View

  1. #1
    Registered User
    Join Date
    05-08-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Copy Pasting data from one excel workbook to another using vba

    Hi Guys,

    I'm a newbie at vba. I want to write a vba script that copies 73 cells from a specific row in an excel sheet and pastes them in a single column in 73 rows in a new document. It then goes back to the old document and copies 73 cells from the next row and pastes them in the new document.

    I want to do the following things using the macro

    1. Open a old.xls document
    2. Open a new new.xls workbook
    3. Copy a range of data from (D9:BX9) //73 cells from old.xls
    4. Paste the copied data from (D2:D74) in new.xls
    5. Go back to data.xls document
    6. Copy the range from (D10:BX10)
    7. Go back to new.xls (opened earlier) and pastes it in (D75:148)
    8. Continues in loop until it reaches an empty cell in data.xls
    9. Saves the new.xls and exits

    I'm trying to use a script I found online and modified a bit. I now just can't make it work. I would be much obliged if someone could help me with this.


    Script

    Sub Copying()
        Application.ScreenUpdating = False
        MyBook = ActiveWorkbook.Name  ' Get name of this  book
        Workbooks.Add ' Open a new workbook
        ThatBook = ActiveWorkbook.Name ' Save name of new book
        
    intRowi = 9
    intColis = 4
    intColie = 77
    intRowo = 2
    intColos = 4
    intColoe = intColos +73
    Do Until objExcel.Cells(intRowi,intColis).Value = ""
        a= objExcel.Cells(intRow, intColumn).Value
    Workbooks(MyBook).Activate ' Back to original book
        Worksheets("old").Activate
        Range("intRowi intColis:intRowi intColie").Select
        Selection.Copy
    Workbooks(ThatBook).Activate
        Range("intRowo intColos: IntRowo intColoe").Select
        Selection.Paste Paste:=xlValues
        Selection.Paste Paste:=xlFormats
    
       intRowi = intRow + 1
       intColos = intColoe + 1
       intColoe = intColos +73 
        
    Loop
    
            SaveAs ("C:\new.xls")
        ActiveWorkbook.Close False
        Application.ScreenUpdating = True
    End Sub
    Last edited by VBA Noob; 05-10-2009 at 05:41 AM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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