![]() |
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. |
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. |
All times are GMT +1. The time now is 03:11 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com