VBA & macros
Automate repeat work with macros and VBA code.
- VBA PivotTable Range: Source, Output, and ExamplesIn VBA, a PivotTable’s source range is the worksheet data used to build or refresh it, while its output range is the…
- VBA PivotTable Object: How It Works and How to Use ItIn Excel VBA, a PivotTable object represents one PivotTable report in a worksheet: its fields, layout, values, and related settings. You can…
- VBA Pivot Table Update: Refresh Tables and ReportsTo update a PivotTable with VBA, call its RefreshTable method; to refresh every PivotTable and external data range in the workbook, use…
- VBA Pivot Table Source Data: Set and Update ItIn Excel VBA, a PivotTable gets its source from a PivotCache: create the cache with a worksheet range or an Excel table,…
- VBA Pivot Table References: Objects, Fields, and ExamplesIn Excel VBA, reference a PivotTable through its worksheet, using Worksheets("SheetName").PivotTables("PivotTableName"); then use that PivotTable object to access its fields, items, ranges,…
- VBA Pivot Table Sort: Code, Options, and Practical FixesTo sort a PivotTable with VBA, use the target row field’s AutoSort method: for example, set its order to xlDescending and name…
- VBA Pivot Table Ranges: How to Set and Resize ThemIn VBA, a PivotTable’s displayed range is read with PivotTable.TableRange2, while its source data range is set through the PivotCache when you…
- VBA Pivot Table Fields: How to Manage ThemIn Excel VBA, a PivotTable’s fields are accessed through its PivotFields collection: set a field’s Orientation to place it in Rows, Columns,…
- VBA Pivot Table Formatting: A Practical GuideTo format an existing Excel PivotTable with VBA, set its TableStyle2 property for an overall design, then set the NumberFormat property of…
- VBA Newline in MsgBox: Add Line BreaksTo add a newline in a VBA MsgBox, join the text with vbCrLf, for example: MsgBox "First line" & vbCrLf & "Second…
- VBA MsgBox Yes/No: Continue If the User Clicks YesUse VBA’s MsgBox with the vbYesNo button option, save the result, and put the work that should continue inside an If answer…
- VBA Nested Dictionary: Create, Read, and Update DataIn VBA, a nested dictionary is a Scripting.Dictionary whose item is another dictionary. Create an outer dictionary, create an inner dictionary for…
- VBA MsgBox Yes No Cancel: Buttons and ExampleTo show Yes, No, and Cancel in a VBA message box, call MsgBox with the vbYesNoCancel button option, then check the result…
- Excel Certifications and Macros: What Exams Actually CoverYes—some Excel certifications assess basic macro skills, but they do not all test them, and a macro task is not the same…
- VBA MsgBox Yes/No: How to Get and Handle the AnswerTo show Yes and No buttons in VBA and read the user’s choice, use vbYesNo and assign the result of MsgBox to…
- VBA MsgBox With a Variable: Examples and TipsTo show a VBA variable in a message box, join it to the message text with the ampersand operator: MsgBox "Hello, "…
- VBA MsgBox Width: What You Can and Can’t ControlVBA’s MsgBox has no width argument or width property, so you cannot set its exact dimensions directly. Its size is chosen by…
- VBA MsgBox Text Formatting: Lines, Buttons, and LimitsVBA’s MsgBox can display plain text, line breaks, tabs, a title, and built-in buttons and icons, but it cannot apply rich text…
- VBA MsgBox String: Build and Display MessagesA VBA MsgBox string is the text you pass to the MsgBox function to display a message in a dialog box. Build…
- VBA MsgBox Scroll: Limits and Scrollable AlternativesNo: VBA’s built-in MsgBox has no setting or argument that adds a scrollbar. For long text, use a VBA UserForm with a…
- VBA MsgBox Select Case: Handle Button ChoicesUse VBA’s MsgBox function to display buttons, store the button the user clicks, and branch on that result with Select Case. For…
- VBA MsgBox Return Values and Button ConstantsIn VBA, MsgBox returns a number identifying the button the user clicked: vbOK is 1, vbCancel is 2, vbYes is 6, and…
- VBA MsgBox Options: Buttons, Icons, and Return ValuesIn VBA, MsgBox displays a dialog with a prompt, optional buttons, an icon, a title, and other settings. Set its button and…
- VBA MsgBox Result: Return Values and Button ChoicesIn VBA, MsgBox returns a VbMsgBoxResult value that identifies which response button the user selected. Store that return value and compare it…
- VBA MsgBox OK Only: Syntax and Button OptionsYes. In Excel VBA, MsgBox displays an OK-only dialog by default, and you can make that choice explicit with vbOKOnly. For example,…
- VBA MsgBox OK Cancel: Button Options and VBA ExamplesYes. In VBA, use vbOKCancel as the buttons argument of MsgBox, then check whether the function returned vbOK or vbCancel. For example,…
- VBA MsgBox OK Button: Syntax, Examples, and ChoicesTo show an OK-only message box in Excel VBA, use MsgBox "Your message", vbOKOnly, "Your title". The OK button is also the…
- VBA MsgBox OK: Syntax, Buttons, and ExamplesYes—VBA’s MsgBox can display a simple OK message, and OK is the default button when you do not specify another button layout.…
- VBA MsgBox Multiple Lines: Line Breaks and ExamplesTo show multiple lines in a VBA MsgBox, join the text with the built-in line-break constant vbCrLf. For example, MsgBox "First line"…
- VBA MsgBox Line Breaks: Add a New Line to a MessageTo start a new line in a VBA MsgBox, join the text with vbCrLf: use MsgBox "First line" & vbCrLf & "Second…