-
VBA樹林
[Excel VBA] How to Prevent a UserForm from Closing (QueryClose Event)
Introduction When creating an input screen with a UserForm, you often need to control how the form closes. For example, you might want to disable the "X" button until a "Terms of Service" checkbox is checked or until all mandatory fields... -
VBA樹林
[Excel VBA] How to Search Cells from Bottom to Top (Using Step -1)
Introduction When working with Excel VBA, you often encounter situations where you need to search for cell contents from the bottom up. For example, you might want to find the very last occurrence of a specific name, like "Mori," in a lo... -
VBA樹林
[Excel VBA] How to Check the Filter Status of All Tables (ListObjects)
Overview When you have multiple Tables (ListObjects) on a worksheet, you may want to instantly know if any of them have filters applied. In this article, I will introduce a VBA macro that loops through all tables on a sheet, checks their... -
VBA樹林
[VBA] How to Use Debug.Assert: A Debugging Technique to Pause Macros When Conditions Fail
Introduction During debugging in VBA, you may encounter situations where you want to pause the program only under specific conditions, such as "stop the macro only when the variable unexpectedly exceeds 100 inside this loop." If you use ... -
VBA樹林
[VBA] How to Automatically Move Focus to the Next TextBox Without Pressing Tab
Introduction When using a VBA UserForm to input dates or times, users often have to type numbers in a sequence like "Year -> Month -> Day -> Hour -> Minute -> Second." Pressing the Tab key after every single entry can be t... -
VBA樹林
[VBA] How to Use Err.Clear: An Essential Technique for Error Handling in Loops
Introduction When writing code in VBA that uses On Error Resume Next to ignore errors, you must be especially careful when using it inside a loop. The VBA Err object retains error information until a new error occurs or the program ends.... -
VBA樹林
[Excel VBA] How to Log Cell Changes Across All Open Workbooks (Application-Level Events)
Introduction If you can automatically record "who changed what, when, and in which file," you can significantly improve the reliability and auditability of your shared data. While the standard Worksheet_Change event can only monitor a si... -
VBA樹林
[Excel VBA] How to Split a String by Underscore and Retrieve Values (Using the Split Function)
Introduction Have you ever wanted to extract specific elements from a string separated by underscores (_), such as filenames or IDs? In this article, I will introduce how to use the VBA Split() function to divide a string by _ and extrac... -
VBA樹林
[Excel VBA] How to Export Table Data as an XML Tree Structure
Introduction There are many situations where you need to export Excel table data as hierarchical XML files for system integration. While manual conversion is difficult, VBA can automate this process. In this article, I will explain pract... -
VBA樹林
[Excel VBA] How to Bulk Delete Hyperlinks (Entire Sheet vs. Specific Ranges)
Introduction In this article, I will explain how to use VBA to bulk delete hyperlinks in Excel. I will cover two scenarios: deleting links from the entire sheet and deleting links from specific cell ranges. Common Use Cases: You want to ... -
VBA樹林
[Excel VBA] How to Automatically Enter a Random Value from a Database into an Adjacent Cell
Introduction With Excel VBA, you can easily extract a random value from a specific cell range (acting as a database) and automatically enter it next to a selected cell. In this article, I will share a macro that randomly picks one item f... -
VBA樹林
[Excel VBA] How to Filter Data by Cell Background Color (AutoFilter Application)
Overview The AutoFilter feature in Excel can filter data based not only on cell values or formulas but also on Fill Color (Background Color). This is extremely useful when you want to efficiently check or correct color-coded data. In thi... -
VBA樹林
[VBA] How to Extract a List of Macro Names from a Module Using Regular Expressions
Introduction As a VBA project grows larger, you might find yourself thinking, "I forgot what macros I wrote in this module," or "I need a list of procedure names to create documentation." By combining the VBA VBProject object with Regula... -
VBA樹林
[Excel VBA] How to Use VLOOKUP for Table Search (Including Error Handling)
Introduction In Excel data processing, the VLOOKUP function is one of the most commonly used tools. You can also utilize this powerful function within VBA macros via the WorksheetFunction object. This allows you to easily automate table ... -
VBA樹林
[Excel VBA] Macro to Paste All Except Borders
Introduction Have you ever ruined the design of a carefully formatted report by pasting cells with thick borders from another location? Using "Paste Special" and selecting "All except borders" is one solution, but it is tedious to do thi... -
VBA樹林
[VBA] How to Delete Only Specific Characters in a Cell (Using Characters().Delete)
Introduction In this article, I will share how to delete only a specific part of a text string within a cell using VBA. Background I encountered a situation where I needed to extract or delete a specific range of characters from a string... -
VBA樹林
[Excel VBA] How to Set UserForm Title and Size via Code
Introduction When creating UserForms in VBA, you typically set the text on the title bar (Caption) and the size of the form (Width and Height) using the Properties window. However, there are times when you want to change these values dyn... -
VBA樹林
[Excel VBA] How to Set Detailed Cell Borders (Using Edge vs. Inside)
Overview In Excel, adding borders to cells helps clarify the structure of a table. There are many situations where you need to apply different settings to specific parts, such as the outer frame, inner lines, top, bottom, left, or right.... -
VBA樹林
[Excel VBA] How to Add Callout Shapes to a Worksheet (Beginner’s Guide)
Introduction When creating documents in Excel, do you ever feel the need to highlight specific cell contents or automatically add annotations to a report? Adding shapes manually can be time-consuming, but with VBA macros, you can instant... -
VBA樹林
[Excel VBA] How to Add a New Workbook and Control It Reliably Using Object Variables
Introduction Aggregating data in VBA and saving the results to a new workbook is a very common task. However, developers often face a problem: "I created a new workbook using Workbooks.Add, but how do I control that specific workbook acc... -
VBA樹林
[VBA] Change Only the Outline Color of a Clicked Shape
Overview In this article, I will introduce a minimal Excel VBA code that changes only the outline color of a shape (button) when you click it. This code targets the specific shape you clicked and does not affect other elements like chart... -
VBA樹林
[Excel VBA] How to Open All Hyperlinks in a Worksheet at Once
It is common to create lists of links in Excel, such as websites, files, or shortcuts to other sheets. However, clicking these links one by one can be time-consuming. This article introduces a method using VBA to automatically open all h... -
VBA樹林
[Excel VBA] How to Change PivotTable Calculation Methods and Number Formats
In Excel PivotTables, numeric fields are automatically summed by default. However, in many business scenarios, you need to calculate averages, counts, or distinct counts instead of sums. Additionally, applying proper number formatting (s... -
VBA樹林
[Excel VBA] Getting the Current Folder (CurDir) and Its Caveats
When handling files in VBA, you may want to base operations on the current working directory, also known as the "Current Folder." For example, if you save a file using only a filename without specifying a full path, it is saved in this c... -
VBA樹林
[VBA Beginners] Preventing Input Errors: How to Set Up Warning Message Boxes for Invalid Data
In Excel, you can use the Data Validation feature to restrict the range or type of values entered into a cell to prevent errors. This article explains how to use VBA to automate this process, specifically focusing on how to display a cus... -
VBA樹林
[Excel VBA] Automating Word Document Formatting: Styles and Alignment
When creating Word documents from Excel using VBA, simply pasting data isn't always enough. You often need to format the document—applying heading styles, centering text, or styling tables—to make it look professional. With VBA, you can ... -
VBA樹林
[VBA] How to Disable (Uninstall) an Excel Add-in Using a Macro
If you distribute specific tools as Excel Add-ins, it is very user-friendly to provide a feature that allows users to temporarily turn off the functionality or easily disable it when it is no longer needed. Asking users to manually open ... -
VBA樹林
[Excel VBA] How to Delete All Sheets Except One Specific Sheet
There are many situations where you want to clear all report sheets created during a previous process before running a macro again, while keeping a specific "Template" or "Master" sheet intact. When deleting multiple sheets in VBA, the m... -
VBA樹林
[VBA] How to Append Values to the Bottom of a Column: Transferring Calculation Results to Another File
In this article, I explain how to use VBA to calculate values in one Excel file and append the result to the bottom of a specific column in a separate file. Background The goal was to calculate the average value of data in Column E of an... -
VBA樹林
[Excel VBA] How to Aggregate Data from Multiple Closed Excel Files
Aggregating data from multiple Excel files is a common business task, but manually opening, copying, and pasting each file is extremely time-consuming. This article explains how to create a VBA macro that automatically opens closed Excel...