How to use On Error GoTo Err1

How to use On Error GoTo Err1



'Paste first

On Error GoTo Err1:

'Paste in End

Err1:

Resume Next


One Line Vba Code:-

 One Line Vba Code:-


1) DISABLE ALERT VBA CODE

Application.DisplayAlerts = False

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


How to use Confirm prompt box in Excel

How to use Confirm prompt box in Excel

Note:- Green hightlight you can change


Dim response As VbMsgBoxResult

    response = MsgBox("Do you want to Import image for ppt ", vbYesNo + vbQuestion, "Confirmation")

    If response = vbYes Then

Else

        MsgBox "Pls Paste image manual for ppt"

       End If

How to Upgrade / Install add ins before file save with confirmation dialog box

 Below copy code for using:-

Note:- below highlight file name add ins (change file name)


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

  ' Display a Yes/No confirmation dialog

    Dim response As VbMsgBoxResult

    response = MsgBox("Do you want to Install/Upgrade add ons? if yes pls select overwrite change in prompt ", vbYesNo + vbQuestion, "Confirmation")

Application.DisplayAlerts = False

    ' Check the user's response

    If response = vbYes Then

       xlamFilePath = Application.UserLibraryPath & "Retail_Add_ons.xlam"

ActiveWorkbook.SaveAs xlamFilePath, FileFormat:=xlOpenXMLAddIn

Else

        MsgBox "Not install only save file "

        ' Add your code to execute when the user clicks No or closes the dialog

    End If

    End Sub




How to Disable excel Vba add ins.

How to Disable excel Vba add ins.

Blue highlight copy for using code

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

Private Sub Workbook_Open()

 Dim addIn As addIn

    ' Loop through each add-in and disable it

    For Each addIn In Application.AddIns

        addIn.Installed = False

    Next addIn

End Sub

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





How to disable right click menu control in excel book

How to disable right click menu control in excel book

Step-1 go to excel vba editor
           go to this this workbook page
          
check below image and paste code

-----------------------------------------------------------------------------
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("cell").Controls("copy").Enabled = True
Application.CommandBars("cell").Controls("cut").Visible = True
End Sub

Private Sub Workbook_Open()
Application.CommandBars("cell").Controls("copy").Enabled = False
Application.CommandBars("cell").Controls("cut").Visible = False
End Sub
----------------------------------------------------------------------------------------

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
---------------------------------------------------------------------------

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