+ Reply to Thread
Results 1 to 2 of 2

How do I 'move' cells from one workbook to another?

  1. #1
    ndm berry
    Guest

    How do I 'move' cells from one workbook to another?

    I have two open workbooks and using a control button I would like to move
    various cells from one workbook to another. There will be different numbers
    of rows each time but the columns will remain the same.

    I am using Excel 2002.

  2. #2
    Jim Thomlinson
    Guest

    RE: How do I 'move' cells from one workbook to another?

    Without knowing more about what is being copied from where to where it is
    hard to comment. Here is some very generic code to copy from one sheet to
    another...

    Sub Test()
    Dim wbkSource As Workbook
    Dim wbkDestination As Workbook
    Dim wksSource As Worksheet
    Dim wksDestination As Worksheet
    Dim rngSource As Range
    Dim rngDestination As Range

    'Set your source
    Set wbkSource = ThisWorkbook
    Set wksSource = wbkSource.Sheets("Sheet1")
    Set rngSource = wksSource.Cells 'Everything on sheet 1

    'Set your destination
    On Error GoTo OpenBook
    Set wbkDestination = Workbooks("ThatBook.xls")
    On Error GoTo 0
    Set wksDestination = wbkDestination.Sheets("Sheet1")
    Set rngDestination = wksDestination.Range("A1")

    'You now have all of your souce and destination objects

    rngSource.Copy rngDestination

    Exit Sub

    OpenBook:
    Set wbkDestination = Workbooks.Open("C:\Thatbook.xls")
    Resume Next
    Exit Sub

    End Sub
    --
    HTH...

    Jim Thomlinson


    "ndm berry" wrote:

    > I have two open workbooks and using a control button I would like to move
    > various cells from one workbook to another. There will be different numbers
    > of rows each time but the columns will remain the same.
    >
    > I am using Excel 2002.


+ 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