VBA & macros
Automate repeat work with macros and VBA code.
- How to Print a Range in VBA: Excel Setup and ExamplesTo print a specific Excel range with VBA, assign it to a Range variable and call its PrintOut method, such as ws.Range("A1:F25").PrintOut.…
- Excel UserForm: How Closely Can It Emulate a Worksheet?Yes, an Excel UserForm can imitate parts of a worksheet, especially a data-entry screen or a simple multi-column record browser, but it…
- Excel UserForm: How to Create, Design, and Use FormsTo create an Excel UserForm in Microsoft 365 for Windows, press Alt+F11 to open the Visual Basic Editor, choose Insert > UserForm,…
- Add Controls to a VBA UserForm: Steps and CodeTo add controls to a VBA UserForm, open the form in the Visual Basic Editor and drag a control from the Toolbox…
- Excel UserForm Date Picker: Options and SetupYes, you can add a date picker to an Excel UserForm, but Excel for Microsoft 365 on Windows does not include a…
- Excel Macro Workbook: What It Is and How to Use OneAn Excel macro workbook is an Excel file that can store and run macros—sets of instructions that automate tasks, usually written in…
- Excel Macro Wait 5 Seconds: VBA Code and Options ExplainedTo make an Excel VBA macro pause for about five seconds, call Application.Wait with a time five seconds in the future. In…
- VBA GoTo: Syntax, Examples, and Safer AlternativesIn VBA, GoTo is a statement, not a function: it transfers execution to a labeled line in the same procedure. It is…
- Hide Column VBA: Methods, Examples, and TroubleshootingTo hide a column with VBA in Excel, set that column’s Hidden property to True, such as Worksheets("Data").Columns("C").Hidden = True. Set it…
- Goal Seek VBA: Automate Excel What-If AnalysisIn Excel VBA, use the GoalSeek method on a formula cell to make it reach a target by changing one input cell.…
- VBA Function Syntax: How to Write and Call FunctionsIn VBA, a function starts with a Function declaration, contains statements that calculate a result, and ends with End Function. Assign the…
- Get Workbook Path in VBA: FullName vs PathTo get a workbook’s folder in VBA, read its Path property; to get the complete location including the file name, read FullName.…
- Excel VBA Range.Formula: How to Read and Set FormulasIn Excel VBA, use a range’s Formula property to read or write a worksheet formula in A1 notation. For example, with a…
- VBA Functions: Basics, Examples, and How to Write ThemA VBA function is a named block of code that performs a task and returns a value. In Excel for Microsoft 365…
- Formula VBA Loop: How Excel Formulas and Loops DifferIn Excel, use a worksheet formula when you want a result that updates as cell values change; use a VBA loop when…
- Named Ranges in Excel VBA: When Do Names Need Quotes?Usually, yes: when you write a named range directly inside a VBA reference such as Range("TaxRate"), put its name in straight double…
- Display MsgBox in VBA: Syntax, Buttons, and ExamplesTo display a message box in VBA, call MsgBox, for example MsgBox "Update complete", vbInformation, "Status". If your macro needs to act…
- Pivot Table VBA: How to Hide SubtotalsTo hide subtotals in an Excel PivotTable with VBA, set the Subtotals property to twelve false values for each row or column…
- Dim Worksheet VBA: Declare and Set a Sheet VariableIn Excel VBA, use Dim ws As Worksheet to declare a variable that can refer to a worksheet; then use Set ws…
- Excel UserForm Controls: A Practical Guide to Types and UseExcel UserForm controls are the buttons, text boxes, lists, and other interface elements you add to a VBA form so people can…
- Dim ws As Worksheet in VBA: Meaning and UseDim ws As Worksheet declares a variable named ws that can refer to an Excel worksheet, but it does not select or…
- Excel UserForm Coding: Build a VBA Data-Entry FormExcel UserForm coding means using VBA to build a custom window for entering, reviewing, or selecting information in a workbook. In Excel…
- Excel UserForm ComboBox: Setup, Code, and Common IssuesAn Excel UserForm ComboBox is a VBA form control that lets someone choose an item from a drop-down list, and, depending on…
- Dim VBA String: How to Declare and Use Text VariablesIn VBA, declare a text variable with Dim variableName As String, such as Dim customerName As String. The Dim statement declares the…
- Excel Macro Type Mismatch: Causes and FixesAn Excel macro “Type mismatch” is VBA run-time error 13: code tried to use a value as a different data type than…
- Excel Macro to Hide Columns: VBA Examples and TipsTo hide columns with a VBA macro in Excel for Microsoft 365 on Windows, put Columns("B:D").Hidden = True in a procedure and…
- Excel Macro to Clear Specific Cells: Safe VBA GuideTo clear chosen cells in Excel with a macro, use VBA’s ClearContents method on a worksheet range. For example, Worksheets("Input").Range("B2,D5,F10:F12").ClearContents removes the…
- Excel UserForm Checkbox: Add, Code, and TroubleshootAn Excel UserForm checkbox is a clickable VBA control that lets someone choose a yes-or-no option in a custom form. In Microsoft…
- VBA Dictionary: How It Works, Examples, and Common UsesA VBA Dictionary is a key–value collection: you store a value under a unique key, then retrieve it quickly by that key.…
- VBA Functions: What They Are and How to Use ThemA function in VBA is a named procedure that performs a task and returns a value. You can call one from another…