Simplify VBA Coding for Common Functions

Add to Favorites
Author: N/A

' These modules exist just to make other VBA code easier to write and more readable

' For example, you can just enter "NormalErrorProcessing" in your code

' instead of "On Error GoTo 0"

Sub NormalErrorProcessing()

    On Error GoTo 0

End Sub

Sub NoErrorProcessing()

    On Error Resume Next

End Sub

Sub EnableScreenUpdating()

    Application.ScreenUpdating = True

End Sub

Sub DisableScreenUpdating()

    Application.ScreenUpdating = False

End Sub

Sub HideGridlines()

    ActiveWindow.DisplayGridlines = False

End Sub

Sub ShowGridlines()

    ActiveWindow.DisplayGridlines = True

End Sub

Sub ToggleGridlines()

    ActiveWindow.DisplayGridlines = Not ActiveWindow.DisplayGridlines

End Sub

Sub TurnOffCalc()

    Application.Calculation = xlCalculationManual

End Sub

Sub TurnOnCalc()

    Application.Calculation = xlCalculationAutomatic

End Sub

Sub ForceFullCalc()

    ActiveWorkbook.ForceFullCalculation = True

End Sub

Sub EnableEvents()

    Application.EnableEvents = True

End Sub

Sub DisableEvents()

    Application.EnableEvents = False

End Sub

Sub UnProtectSheet()

    ActiveSheet.Unprotect

End Sub

Sub TurnOnFormulaBar()

    Application.DisplayFormulaBar = True

End Sub

Sub TurnOffFormulaBar()

    Application.DisplayFormulaBar = False

End Sub

Sub ToggleFormulaDisplay()

    ActiveWindow.DisplayFormulas = Not ActiveWindow.DisplayFormulas

End Sub

Sub TurnOffFilters()

    ActiveSheet.AutoFilterMode = False

End Sub

Sub ResetScroll()

    ActiveSheet.ScrollArea = ""

End Sub

 


Question? Ask it in our Excel Forum


Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons 50+ Hours of Instruction 200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Similar Content on TeachExcel
Simple Excel Function to Extract a Word or Text from a Cell
Tutorial: Excel function that makes it easy to extract a word or text from a cell in Excel. This is ...
Simple Excel Function to Combine Text with a Separator
Tutorial: Excel function that makes combining text very easy. This function is simpler and better th...
Understanding Formulas and Functions in Excel
Tutorial: In this tutorial I will cover the basic concepts of Formulas and Functions in Excel. A for...
VLOOKUP() Function in Excel
Tutorial: Full explanation of the Vlookup function in Excel, what it is, how to use it, and when yo...
Create a Custom Function in Excel - UDF
Tutorial: How to create a custom worksheet function in Excel. These are called User Defined Function...
Get User Submitted Data from a Prompt in Excel using VBA Macros
Tutorial: How to prompt a user for their input in Excel. There is a simple way to do this using VBA ...
Tutorial Details
Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course