Question How to copy from one workbook to another? I’m trying to search for text "Total LOE" that is on a closed workbook and copy the row to an open workbook. This macro works however I have to open the workbook that contains the "Total LOE" and copy it manually.
I sincerely appreciate your advice.
sub CopyLOE()
Dim ws As Worksheet
Dim DataFile As String
Set ws = ActiveSheet
MsgBox ("Please select a file to copy data from.")
DataFile = Application.GetOpenFilename("Excel Files(*.xls; *.xlsx; *.xlsm), *.xls; *.xlsx; *.xlsm", 1, "Select One File To Open", , False)
If DataFile <> "False" Then
Workbooks.Open DataFile, UpdateLinks:=False
Range("A41:N41").Copy
ws.Range("A85").PasteSpecial xlPasteValues
ActiveWorkbook.Close False
End If
End Sub
I sincerely appreciate your advice.
sub CopyLOE()
Dim ws As Worksheet
Dim DataFile As String
Set ws = ActiveSheet
MsgBox ("Please select a file to copy data from.")
DataFile = Application.GetOpenFilename("Excel Files(*.xls; *.xlsx; *.xlsm), *.xls; *.xlsx; *.xlsm", 1, "Select One File To Open", , False)
If DataFile <> "False" Then
Workbooks.Open DataFile, UpdateLinks:=False
Range("A41:N41").Copy
ws.Range("A85").PasteSpecial xlPasteValues
ActiveWorkbook.Close False
End If
End Sub