I am getting the error Compile error: Syntax error on this line of code:
Set wbSource = Workbooks.Open Filename
the wbSource variable is declared.
What else might be going on?
Set wbSource = Workbooks.Open Filename
the wbSource variable is declared.
What else might be going on?
Code:
Sub GetOpenFName()
Dim FileName As Variant
Dim Filt As String, Title As String
Dim FilterIndex As Integer, Response As Integer
Dim wbSource As Workbook
Dim wbDest As Workbook
Set wbDest = ActiveWorkbook
' Set to Specified Path\Folder
On Error Resume Next
ChDir ActiveWorkbook.Path
' Set File Filter
'Filt = "Excel Files (*.xls, *.xlsx, *.xlsm, *.xlsb), *.xls, *.xlsx, *.xlsm, *.xlsb"
' Set *.* to Default
'FilterIndex = 5
' Set Dialogue Box Caption
Title = "Please select a different File"
' Get FileName
FileName = Application.GetOpenFilename(FileFilter:=Filt, FilterIndex:=FilterIndex, Title:=Title)
' Exit if Dialogue box cancelled
If FileName = False Then
Response = MsgBox("No File was selected", vbOKOnly & vbCritical, "Selection Error")
Exit Sub
End If
' Display Full Path & File Name
Response = MsgBox("You selected " & FileName, vbInformation, "Proceed")
' Open Selected Workbook
Set wbSource = Workbooks.Open FileName
'Copy from source workbook to dest workbook
wbSource.Sheets("RawData").Range("A1:S29089").Copy wbDest.Sheets(“DataCalcs”).Range(“A1”)
End Sub
Last edited by a moderator: