How to ignore vba excel error runtime error '1004'



How to ignore vba error runtime error 1004

Question-when not select file then show below runtime error
below 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
---------------------------------------------------------------------------

How to Browse file and open select file vba code

How to Browse file and open select file vba code
Below vba code
--------------------------------------------------------------------------------------------------------
Sub browsefileopen()
'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


End Sub

-----------------------------------------------------------------------------------------------------------------

This workbook contains links to other data sources-Excel vba code



Question-How to Disable alert box  This workbook contains links to other data sources Excel       vba code

worning altert-1
This workbook contains links to other data sources



Worning Alert-2
This workbook contains one or more links that cannot be updated


Answer Solution-' Disaple Update link alert prompt box

Try below code:-


Application.AskToUpdateLinks = False
Application.DisplayAlerts = False


Try below code-

 Workbooks.Open Filename:=FullFileName, UpdateLinks:=0
Try below code-

Application.ScreenUpdating = False


How to Move Excel sheet Data to Other workbook

Example1:-Move Excel sheet Data to Other workbook

Copy Below Code and Paste in Module


Sub movefileotherworkbook()
Workbooks.Open Filename:="C:\NitinVbaAppAMD\nitin1.xlsx"
ActiveSheet.Range("A2:F4").Copy

Workbooks.Open Filename:="C:\NitinVbaAppAMD\nitin2.xlsx"
'eColumn = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
'If eColumn >= 1 Then eColumn = eColumn + 1
ActiveSheet.Cells(1, 1).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, Skipblanks:=False, Transpose:=True
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.CutCopyMode = False

End Sub

Note:-Green Highlight you can Update/change 
Note this code not paste nitin1 and nitin2 please paste another for run macro.



About Me

author Click here for Connect FB

Click here for Linkedin

Related Post No.

Powered by Blogger.

Contact Form

Name

Email *

Message *

Search This Blog

Recent Posts

Breaking

Recent Posts

Trending Topic

Breaking

Related Post No.

Pages