I watched this video on YouTube and it really helped me a lot, now I have to improve that code. So in the code where is the line for pasting the values I have to set inputbox or something else, to let user choose where he wants to paste it. Here is my code:
Sub IMPORT_DATA()
Dim FileToOpen As Variant
Dim OpenBook As Workbook
Application.ScreenUpdating = False
FileToOpen = Application.GetOpenFilename(Title:="Browse for your File & Import Range", FileFilter:="Excel Files(*.xlsx),*xlsx")
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)
OpenBook.Sheets("NELT report").Range("R7:R14").Copy
ThisWorkbook.Worksheets("Dispatch Monthly NETO").Range("L5").PasteSpecial xlPasteValues
OpenBook.Close False
Range("L5:L12").Interior.Color = RGB(255, 242, 204)
End If
Application.ScreenUpdating = True
End Sub
CodePudding user response:
Sub IMPORT_DATA()
Dim FileToOpen As Variant
Dim OpenBook As Workbook
Dim s As String ' Range to Paste
Application.ScreenUpdating = False
FileToOpen = Application.GetOpenFilename(Title:="Browse for your File & Import
Range", FileFilter:="Excel Files(*.xlsx),*xlsx")
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)
OpenBook.Sheets("NELT report").Range("R7:R14").Copy
s = InputBox("Range to Paste : ")
If s = "" Then Exit Sub
ThisWorkbook.Worksheets("Dispatch Monthly NETO").Range(s).PasteSpecial
xlPasteValues
OpenBook.Close False
Range("L5:L12").Interior.Color = RGB(255, 242, 204)
End If
Application.ScreenUpdating = True
End Sub