C
clive.m.orourke
Hello!
I need to run a macro that will copy a line of data from one workbook into another. The originating workbook will be one of 575 emailed to me. I recorded a macro to do this which works fine. The problem arises (I think) because windows/excel autonames the second workbook I open with a (2) suffix, followed by (3), (4) and so on.
Please could you advise how I amend the code below so I do not have this problem.
Thanks.
Sub AutoCopy()
'
' AutoCopy Macro
'
'
Windows("EK LPM Preferences v1.0.xls").Activate
Rows("2:2").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Windows("EK LPM Requests v1.3.xls").Activate
Sheets("Selected Data").Select
Rows("2:2").Select
Selection.Copy
Windows("EK LPM Preferences v1.0.xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("2:2").EntireRow.AutoFit
Selection.Font.Bold = False
Range("J2").Select
ActiveCell.FormulaR1C1 = "=R[1]C+1"
Range("J2").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.Save
Windows("EK LPM Requests v1.3.xls").Activate
End Sub
I need to run a macro that will copy a line of data from one workbook into another. The originating workbook will be one of 575 emailed to me. I recorded a macro to do this which works fine. The problem arises (I think) because windows/excel autonames the second workbook I open with a (2) suffix, followed by (3), (4) and so on.
Please could you advise how I amend the code below so I do not have this problem.
Thanks.
Sub AutoCopy()
'
' AutoCopy Macro
'
'
Windows("EK LPM Preferences v1.0.xls").Activate
Rows("2:2").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Windows("EK LPM Requests v1.3.xls").Activate
Sheets("Selected Data").Select
Rows("2:2").Select
Selection.Copy
Windows("EK LPM Preferences v1.0.xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("2:2").EntireRow.AutoFit
Selection.Font.Bold = False
Range("J2").Select
ActiveCell.FormulaR1C1 = "=R[1]C+1"
Range("J2").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.Save
Windows("EK LPM Requests v1.3.xls").Activate
End Sub