I have a Master spreadsheet which loads up data from various sources and
saves itself under a new name with the current date, i.e. Master20060712.xls
The user can then work on the spreadsheet with the new name and add
comments, etc in certain columns.
I have been trying to copy some columns of data from the new spreadsheet
to the original, I started out by using the Record Macro and got the following
code.
VB Code:
Workbooks.Open Filename:= ThisWorkbook.Path & "\" & MasterWBK Windows("Master20060712").Activate Columns("I:Q").Select Selection.Copy Windows("Master.xls").Activate Range("I1").Select ActiveSheet.Paste
I adapted it as follows :-
VB Code:
' Declared Elsewhere Const MasterWBK = "Master.xls" ' Placed in the Workbook_BeforeClose Sub If ThisWorkbook.Name <> MasterWBK Then ' Dont do this if I am working in the Original File Workbooks.Open Filename:= ThisWorkbook.Path & "\" & MasterWBK ThisWorkbook.Activate Columns("I:Q").Select Selection.Copy Workbooks(MasterWBK).Activate Range("I1").Select ActiveSheet.Paste Workbooks(MasterWBK).Close SaveChanges:=True End If
For some reason when I run this, although it seems to work it does save
the pasted data.
Can anyone offer any advice as to why this is not working properly.
I have since changed to using the following simplistic code, but would like to know why the above did not work.
![]()
VB Code:
Row = 1 Do Col = 9 Do Workbooks(MasterWBK).ActiveSheet.Cells(Row,Col).Value = ThisWorkbook.ActiveSheet.Cells(Row,Col).Value Col = Col + 1 If ExitConditions Then Exit Do End If Loop Row = Row + 1 If ExitCondition Then Exit Do End If Loop




, but would like to know why the above did not work.

Reply With Quote