Forum Discussion
Lorenzo Kim
Jul 10, 2018Bronze Contributor
opening a file from file dialog box
The SUB below copies a range from a worksheet of another workbook (selected from file dialog box) then paste it (values only) on the opened "RaD Analyzer.xlsm" file.. I am requesting for a vba for f...
- Jul 11, 2018
Hi Lorenzo,
The last one you mentioned is the best.
It seems that my suggestion is not perfect as it brings only the opened Excel files into the dropdown list.
However, I've updated the last code you mentioned this way so that it closes the source file after complete the process.
Also, I've deleted this variable because it's unused!
Dim mwrbk As Variant
This is the updated code:
Sub CopyFromSource2()
On Error Resume Next
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim strFileToOpen As String
strFileToOpen = Application.GetOpenFilename _
(Title:="Please choose a file to open", _
FileFilter:="")
Set targetedWB = Workbooks.Open(strFileToOpen)
Dim LastRow As Long
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Range("A2:J" & LastRow).Select
Selection.Copy
Windows("RAD Analyzer.xlsm").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
targetedWB.Close SaveChanges:=False
Range("A2").Select
On Error GoTo 0
Application.CutCopyMode = False
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End SubRegards
Lorenzo Kim
Jul 22, 2018Bronze Contributor
Mr. Amairah pardon my butting in the query below. I'd posted it at the forum for quite sometime now and haven't had any reply. I am just curious what the statement below means. if you would indulge me on this... many many thanks "you have earned so and so subscriptions"
Haytham Amairah
Jul 23, 2018Silver Contributor
Hi Lorenzo,
What is the statement you are asking for?