'VBA Debug showing error in the highlighted line. I need a selection i.e. range to be dynamic
Error is "script out of range". I want range selection to be relative i.e dynamic.
Sub input_file()
Dim FileToOpen As Variant
Dim Openbook As Workbook
Application.ScreenUpdating = False
FileToOpen = Application.GetOpenFilename(Title:="Browse for your File & Import Range", FileFilter:="Excel Files(*.xls*),*xls*")
If FileToOpen <> False Then
Set Openbook = Application.Workbooks.Open(FileToOpen)
Openbook.Sheets(2).Range("A2:AZ2").Copy
ThisWorkbook.Worksheets("SelectFile").Range("A3").Active.PasteSpecial xlPasteValues
OpenWorkbook.Close False
End If
Application.ScreenUpdating = True
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
