+ Reply to Thread
Results 1 to 2 of 2

copying cells from one wkbk to another

  1. #1
    Registered User
    Join Date
    06-08-2005
    Posts
    67

    copying cells from one wkbk to another

    I want to copy a series of cells from wkbk to another, but I need to do it one cell at a time (because of some additional processing) instead of just a straight select/copy/paste. How do I define the range of cells in my destination workbook so I can copy to them. I need to open the destination wkbk & define the destination cells. This code kind of gives the idea...

    Sub Macro1()
    Dim ocells As Range
    Set ocells = Range("a1:a5")

    Dim nwkbk As Workbook
    Set nwkbk = Workbooks.Open(ThisWorkbook.Path & "\Book2.xls")

    dim ncells as range
    set ncells = ??????

    For i = 1 To 5
    ncells(i) = ocells(i) ' How do I do this across wkbks then save nwkbk
    Next i

    nwkbk.Save
    nwkbk.Close
    End Sub

  2. #2
    Tom Ogilvy
    Guest

    RE: copying cells from one wkbk to another

    Use the top left corner of the destination and make it the same size


    Sub Macro1()
    Dim ocells As Range
    Set ocells = Range("a1:a5")

    Dim nwkbk As Workbook
    Set nwkbk = Workbooks.Open(ThisWorkbook.Path & "\Book2.xls")

    dim ncells as range
    set ncells = Range("B10").Resize(oCells.Rows.count,oCells.columns.count)

    For i = 1 To 5
    ncells(i) = ocells(i) ' How do I do this across wkbks then save
    nwkbk
    Next i

    nwkbk.Save
    nwkbk.Close
    End Sub

    --
    Regards,
    Tom Ogilvy

    "mwc0914" wrote:

    >
    > I want to copy a series of cells from wkbk to another, but I need to do
    > it one cell at a time (because of some additional processing) instead
    > of just a straight select/copy/paste. How do I define the range of
    > cells in my destination workbook so I can copy to them. I need to open
    > the destination wkbk & define the destination cells. This code kind of
    > gives the idea...
    >
    > Sub Macro1()
    > Dim ocells As Range
    > Set ocells = Range("a1:a5")
    >
    > Dim nwkbk As Workbook
    > Set nwkbk = Workbooks.Open(ThisWorkbook.Path & "\Book2.xls")
    >
    > dim ncells as range
    > set ncells = ??????
    >
    > For i = 1 To 5
    > ncells(i) = ocells(i) ' How do I do this across wkbks then save
    > nwkbk
    > Next i
    >
    > nwkbk.Save
    > nwkbk.Close
    > End Sub
    >
    >
    > --
    > mwc0914
    > ------------------------------------------------------------------------
    > mwc0914's Profile: http://www.excelforum.com/member.php...o&userid=24130
    > View this thread: http://www.excelforum.com/showthread...hreadid=572343
    >
    >


+ 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