Hello All. My name is Joe. I consider myself an intermediate user of excel. I do NOT speack any Visual Basic.
I am trying to create, what I feel Should be a simple Macro but I am stumbling over one detail.
I need to copy information from one Workbook to another. But I need the macro to be applicable to any two workBooks laid out in the same way. ( I have a program that exports data in the same format every time, and I have multiple different templates laid out the same to copy the data into).
Below is the macro excel generated for me, and works very well, but will only work for the documents hard coded into it.
Thanks In Advance!!
Joe
**I apologize if this has been addressed before, I've found a few threads around the internet on similar topics, but none of the solutions seemed to help me**
I am trying to create, what I feel Should be a simple Macro but I am stumbling over one detail.
I need to copy information from one Workbook to another. But I need the macro to be applicable to any two workBooks laid out in the same way. ( I have a program that exports data in the same format every time, and I have multiple different templates laid out the same to copy the data into).
Below is the macro excel generated for me, and works very well, but will only work for the documents hard coded into it.
Thanks In Advance!!
Joe
**I apologize if this has been addressed before, I've found a few threads around the internet on similar topics, but none of the solutions seemed to help me**
Code:
Sub Transfer()'
' Transfer Macro
'
' Keyboard Shortcut: Ctrl+t
'
Windows("orchard market fruitport.xls").Activate
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("G8").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("K2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("J3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("D9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 13
Range("Q2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("G10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("R2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("G11").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 15
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 17
ActiveWindow.ScrollColumn = 18
Range("T2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("J10").Select
ActiveSheet.Paste
Windows("orchard market fruitport.xls").Activate
Range("S2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("J11").Select
ActiveSheet.Paste
Windows("orchard market fruitport.xls").Activate
ActiveWindow.ScrollColumn = 17
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 15
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 9
Range("K2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("B13").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("L2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("B14").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("M2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("B15").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("N2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("B16").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("O2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("D16").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("P2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("G16").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 15
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 17
ActiveWindow.ScrollColumn = 18
ActiveWindow.ScrollColumn = 19
ActiveWindow.ScrollColumn = 20
Range("U2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("J13").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("V2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("J14").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("W2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("J15").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("X2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("J16").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("Y2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("J17").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("Z2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("K17").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("AA2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("M17").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Columns("AB:AB").ColumnWidth = 7
Range("AC2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "="
Range("AC2").Select
ActiveCell.FormulaR1C1 = "= IF(1,""COD"",""CHARGE"")"
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("J8").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
ActiveWindow.ScrollColumn = 22
ActiveWindow.ScrollColumn = 21
ActiveWindow.ScrollColumn = 20
ActiveWindow.ScrollColumn = 19
ActiveWindow.ScrollColumn = 18
ActiveWindow.ScrollColumn = 17
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 15
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Range("B2:B17").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
ActiveWindow.SmallScroll Down:=12
Range("B22:B44").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("F2:F17").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("D22:D37").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("G2:G17").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("G22:G38").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("H2:H17").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("M22:M37").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("I2:I17").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("K22:K37").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("D2:D17").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("H22:H37").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("orchard market fruitport.xls").Activate
Range("E2:E17").Select
Application.CutCopyMode = False
Selection.Copy
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
Range("J22:J37").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWindow.SmallScroll Down:=-24
Windows("orchard market fruitport.xls").Activate
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 15
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 17
ActiveWindow.ScrollColumn = 18
ActiveWindow.ScrollColumn = 19
ActiveWindow.ScrollColumn = 20
ActiveWindow.ScrollColumn = 21
ActiveWindow.ScrollColumn = 22
ActiveWindow.ScrollColumn = 23
Windows("LINEN SERVICE AGREEMENT Template.xls").Activate
End Sub