How to ignore vba error runtime error 1004
Question-when not select file then show below runtime errorbelow image
below copy code and paste modules
----------------------------------------------------------------------------------------------
Sub browsefileopen()
' step 1 below code for ignore runtime error
On Error Resume Next
'below browse file code
myfile = Application.GetOpenFilename(, , "Browse for File")
'browse filename update with file location in active sheet.
ThisWorkbook.Sheets("sheet1").Range("a2") = myfile
'select browse file open code
Workbooks.Open myfile
' step 2 below code for ignore runtime error
On Error GoTo 0
End Sub
---------------------------------------------------------------------------