Hi Allen
This will open a designated workbook paste the data from the sheet you
run it from, close the workbook saving the changes. You will have to
adjust the sheet name, the file path and the copy range.
Take care
Marcus
Option Explicit
Sub OpenXL()
Dim oWbk As Workbook
Dim sFil As String
Dim sPath As String
Dim twbk As Workbook
Dim lr As Integer
Dim lw As Integer
Dim strFullName As String
Set twbk = ActiveWorkbook
Application.DisplayAlerts = False
Application.ScreenUpdating = False
lw = Range("A" & Rows.Count).End(xlUp).Row
twbk.Sheets("Sheet1").Range("A2:A" & lw).Copy
sPath = "R:\" 'Cell B2 of Cal sheet, location of files
ChDir sPath
sFil = Dir("Test.xls") 'change or add formats
strFullName = sPath & sFil
Set oWbk = Workbooks.Open(strFullName)
lr = oWbk.Sheets("FS Data").Range("A" & Rows.Count).End(xlUp).Row + 1
oWbk.Sheets("FS Data").Range("A" & lr).PasteSpecial xlPasteValues
oWbk.Close True 'close the workbook, saving changes
sFil = Dir
End Sub
|