Hello,
I get Compile error in highlighted code. I have many such codes on the same spreadsheet under Userform1 button and it works fine. I added this code in Userform2 and I get this error message.![]()
Dim sImportFile As String, sFile As String Dim sThisBk As Workbook Dim vfilename As Variant Application.ScreenUpdating = False Application.DisplayAlerts = False Set sThisBk = ActiveWorkbook sImportFile = Application.GetOpenFilename( _ fileFilter:="Microsoft Excel Workbooks, *.xls; *.xlsx", Title:="Open Workbook") If sImportFile = "False" Then MsgBox "No File Selected!" Exit Sub Else vfilename = Split(sImportFile, "\") sFile = vfilename(UBound(vfilename)) Application.Workbooks.Open Filename:=sImportFile Set wbBk = Workbooks(sFile) With wbBk If SheetExists("Submit Payroll Input") Then Set wsSht = .Sheets("Submit Payroll Input") wsSht.Copy After:=sThisBk.Sheets("Sheet1") Else MsgBox "There is no sheet with name :Raw_Data in:" & vbCr & .Name End If wbBk.Close savechanges:=False End With End If Application.ScreenUpdating = True Application.DisplayAlerts = True
any idea why I am getting this error message.
Thanks
Bookmarks