Good day!
I have the following code which successfully:
- Opens a CSV
- Copies a range in the CSV
- Pastes values in active workbook
- Closes CSV
However I need the code to open a different CSV each time (based on a named range not a file path).
Could someone please have a look at the below code and help me in correcting this?
Thanking you in advance!
Paul
Sub Import_test()
Dim wb As Workbook
Dim rng As Range
Dim lastRow As Long
Application.ScreenUpdating = False
Set wb = Workbooks.Open("F:\Sales\Lookup files\Quote_data\QU14022539.csv", True, True)
Set rng = wb.Worksheets("QU14022539").Range("A1:D21")
With ThisWorkbook.Worksheets("Sheet2")
rng.Copy
.Range("D2").PasteSpecial Paste:=xlValues
End With
wb.Close False
Set wb = Nothing
Application.ScreenUpdating = True
End Sub
Bookmarks