I have the following macro which copies data from one spreadsheet to another spreadsheet. The 2 files are specifically named in the database so they must have those specific file names in order for the macro to work.
Is there a way to set up this macro so that it automatically copies the data in the file that is active at the time (File1 in the attached code) to File2? File2 will always be the same file name, so that part of the macro is fine as it is. The active spreadsheet will always be the same format (so the Source Cells will work) but it may have a different file name each time.
Sub DatabaseCopy()
'
' DatabaseCopy Macro
' Macro recorded 11/12/2008 by JLZ
'
' Keyboard Shortcut: Ctrl+d
'
Range("B6:E9").Select
Selection.Copy
Range("B6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Dim wks1 As Worksheet
Dim wks2 As Worksheet
Set wks1 = Workbooks("File1.xls").Worksheets("Sheet1")
Set wks2 = Workbooks("File2.xls").Worksheets("Sheet1")
' syntax is [destination].Value = [source].Value
wks2.Range("A3").Value = wks1.Range("C9").Value
wks2.Range("B3").Value = wks1.Range("E2").Value
wks2.Range("C3").Value = wks1.Range("E3").Value
wks2.Range("D3").Value = wks1.Range("E4").Value
wks2.Range("E3").Value = wks1.Range("C6").Value
Bookmarks