Application Object VBA
Application object contains application-wide settings and options. Below are few commondly used codes to control events using Application object.
Application.CutCopyMode=False
Once the vba code copies a data and to remove the highlighted selection use the above command. It’s equivalent to hitting “Esc” key in Excel.
Example:
Sub macro1()
Range(“a1:a10”).copy
Sheets(“Upskill”).select
Range(“a1”).pastespecial paste:=xlvalues
Application.cutcopymode=false
End sub
Application.Screenupdating=False
Used to disable the screen updating which will also enhance the speed.
Application.Displayalerts=False
Used to avoid the alert dialog box. For example the below code will generate an alert if displayalert is not set to false.
Example:
Sub macro2()
Sheets(“Upskill”).delete
End sub
Application.Windowstate=xlMaximized
To turn the screen mode to full screen
Application.Windowstate=xlMinimized
Minimized State
Application.Windowstate=xlNormal
Normal state
Application.Username
To get the user name of excel. It’s the same what comes in a comment box when you add a comment in a cell.
Application.EnableEvents=False
Disable excel events.
Application.Calculation=xlCalculationManual
Change the excel calculation to manual
Application.Calculation=xlCalculationAutomatic
Change the excel calculation to automatic
- Call us for any training requirement on excel, vba macros, access, financial modelling. Reach out to us at 9985130004. For enquiries outside India please dial in our US number 253-243-1476. Or drop an email to info@upskilltechnologies.com