I have a macro that allows me to select files in a directory. I would like to amend the macro that if I select another file after the first file, the macro will automatically take the user to the last file selected. The reason for this is that I have many files in this directory and the next file to be selected will be very close to where the first file is
Your assistance in this regard is most appreciated
Code:
Sub Open_Workbook()
ChDir ("C:\downloads")
A:
Dim A As Variant
Dim LR As Long
With Sheets("Data Import")
LR = Cells(Rows.Count, "A").End(xlUp).Row
Range("A1:AJ" & LR).ClearContents
End With
If msg <> "" Then MsgBox msg
A = Application.GetOpenFilename
If A = False Or IsEmpty(A) Then Exit Sub
Application.ScreenUpdating = False
With Workbooks.Open(A)
msg = msg & vbCr & A
With Sheets(1)
.Range("a1", .Range("J" & Rows.Count).End(xlUp)).Copy _
Destination:=ThisWorkbook.Sheets("Data Import").Range("A" & Rows.Count).End(xlUp).Offset(1)
End With
.Close SaveChanges:=False
End With
answer = MsgBox("Does another file needs to be selected?", vbYesNo + vbQuestion, "Hello")
If answer = vbYes Then
GoTo A:
End If
Application.ScreenUpdating = True
End Sub
Your assistance in this regard is most appreciated