I have an excel file that is updated each week with data from another excel file. The data is copied and pasted manually with edit paste special. At this point, because the position of the incoming data as well as the position as to where the data will be placed in the main spreadsheet (different groups of data will be going to different tabs within the destination spreadsheet) can be different each week, I don't think the process can be fully automated. What I was hoping could happen is that if I place the cursor on the first cell in the source sheet and click the cursor in the first cell in the destination the code could then Copy Paste Special Values for 5 cells (G2:G6 for example) into the other file to the position of the cursor.
Example of Source data
[tt]
2006 F 2006/06/03 SC MSF APP 5
2006 F 2006/06/03 sc MSF ACC 18
2006 F 2006/06/03 sc MSF CAN 9
2006 F 2006/06/03 sc MSF DEN 22
2006 F 2006/06/03 sc MSF ITE 44
2006 F 2006/06/03 BN MBA APP 67
2006 F 2006/06/03 BN MBA ACC 5
2006 F 2006/06/03 BN MBA CAN 2
2006 F 2006/06/03 BN MBA DEN 0
2006 F 2006/06/03 BN MBA ITE 25
[/tt]
SC data will go to the SC tab in the destination while BN data will go to the BN tab in the destination file. Each week is set up as its own col. in the destination so for example the week may be in col. Z and next week the data will go in col. AA. Only the col with data will actually be copied from the source to the destination. Needs to be copied as values due to formatting and where the data originally came from.
-----------------------
On a related note, I have another spreadsheet where the information is more "fixed" and set up code that successfully transfers data between source file to destination and correct tab within destination. If I start appending data to this file, to create one master source, rather than having a separate copy for each week, how can I adjust the logic so that it will be able to pick up the correct data, by date?
This is the code I have for the data that has a "fixed" position each week. This code is "hands off" meaning I don't have to do any manual copy or paste, whereas the code I create for above probably would need to have more manual intervention due to the variability in the source data groups.
Example of Source data
[tt]
2006 F 2006/06/03 SC MSF APP 5
2006 F 2006/06/03 sc MSF ACC 18
2006 F 2006/06/03 sc MSF CAN 9
2006 F 2006/06/03 sc MSF DEN 22
2006 F 2006/06/03 sc MSF ITE 44
2006 F 2006/06/03 BN MBA APP 67
2006 F 2006/06/03 BN MBA ACC 5
2006 F 2006/06/03 BN MBA CAN 2
2006 F 2006/06/03 BN MBA DEN 0
2006 F 2006/06/03 BN MBA ITE 25
[/tt]
SC data will go to the SC tab in the destination while BN data will go to the BN tab in the destination file. Each week is set up as its own col. in the destination so for example the week may be in col. Z and next week the data will go in col. AA. Only the col with data will actually be copied from the source to the destination. Needs to be copied as values due to formatting and where the data originally came from.
-----------------------
On a related note, I have another spreadsheet where the information is more "fixed" and set up code that successfully transfers data between source file to destination and correct tab within destination. If I start appending data to this file, to create one master source, rather than having a separate copy for each week, how can I adjust the logic so that it will be able to pick up the correct data, by date?
This is the code I have for the data that has a "fixed" position each week. This code is "hands off" meaning I don't have to do any manual copy or paste, whereas the code I create for above probably would need to have more manual intervention due to the variability in the source data groups.
Code:
Sub CP_UPaste()
'
' CP_UPaste Macro
' Macro recorded 5/19/2006 by ITS Image
'
'Copy Data from CP-SUM Report and paste in corresponding tab
'uses weekno as reference to the col to paste the data in. Assumes
'paste into row 6 for Current Year Totals
'
Dim stSheet As String
Dim stRange As String
Dim i As Integer
Dim intWeekno As Integer
Dim stFileName As String
stFileName = "C:\Documents and Settings\ACCOUNTS\My Documents\Stats\Data\"
Workbooks.Open Filename:=stFileName & "CP_U.xls"
Windows("06F_A.xls").Activate
For i = 1 To 4
Select Case i
Case Is = 1
stSheet = "CP"
stRange = "2"
Case Is = 2
stSheet = "CP-Summer"
stRange = "14"
Case Is = 3
stSheet = "CP-Off"
stRange = "8"
Case Is = 4
stSheet = "CP-Off-Summer"
stRange = "20"
End Select
Sheets(stSheet).Select
Windows("CP_U.xls").Activate
Range("F" & stRange & ":F" & stRange + 5).Select
Selection.Copy
Windows("06F_A.xls").Activate
Cells(6, Sheets("Temp Data").[Q111]).Select 'Dynamically Refer to Col Letters
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Next i
Sheets("PSTotal").Activate
Selection.Copy
Cells(6, Sheets("Temp Data").[Q111]).Select 'Dynamically Refer to Col Letters
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub