-
VBA樹林
[VBA] Guide to Using ComboBoxes: Creating Drop-down Lists and Getting Values
In VBA UserForms, the "ComboBox" control is very useful when you want users to choose one item from a predefined list, such as department names or product categories. Since choices appear in a drop-down format when clicked, it also helps... -
VBA樹林
[VBA] Basic Error Handling: How to Use On Error GoTo
When running a VBA macro, if you try to select a sheet that doesn't exist or divide a number by zero, an error occurs, and the program stops forcibly. This is not a good experience for the user. By using the On Error GoTo statement in VB... -
VBA樹林
[Excel VBA] How to Process Only Visible Cells (Excluding Hidden Rows and Filters)
In Excel, rows and columns are often hidden by AutoFilter or manual hiding. In such cases, you often want to process only the cells that are currently visible. In VBA, you can use SpecialCells(xlCellTypeVisible) to extract and manipulate... -
VBA樹林
[Excel VBA] How to Extract Data Using the FILTER Function into an Array
Traditionally, extracting specific rows of data based on criteria involved using AutoFilter with copy-paste or looping through rows one by one. However, in Excel for Microsoft 365 and Excel 2021 or later, the powerful dynamic array funct... -
VBA樹林
[Excel VBA] How to Read UTF-8 Files and Output to Cells Using ADODB.Stream
There are several ways to read files in Excel VBA. However, when you need to specify character encoding or require precise control over the data, using ADODB.Stream is the most effective method. This article explains how to use the ADODB... -
VBA樹林
[Excel VBA] How to Select Cells, Rows, and Columns Relative to a Range
When manipulating table data in VBA, you often need to extract specific cells, rows, or columns from a defined range. This article explains how to select individual elements from a specific range, such as Range("B2:F4"), using simple cod... -
VBA樹林
[Excel VBA] How to Import CSV Data to a Specific Location Using QueryTable
When importing CSV files into Excel, simply opening the file and copying the data can be tedious. Using the VBA QueryTable feature allows you to automate this process and gives you flexible control over how the data is loaded. This artic... -
VBA樹林
[VBA] How to Wait for an External Application to Close (Windows API)
Introduction When you launch an external application using the Shell function in VBA, VBA only starts the application and immediately proceeds to the next line of code without waiting for it to finish. However, there are times when you w... -
VBA樹林
[Excel VBA] How to Apply the Same Process to Selected Multiple Sheets (Work Group) at Once
Adding the same header, updating the same cell value, or applying the same print settings to multiple sheets... There are many situations in Excel where you want to perform the exact same operation on several sheets. Using VBA, you can e... -
VBA樹林
[VBA] How to Skip to the Next Iteration in a For Loop (Simulating Continue)
Introduction When using a For loop in VBA, you often encounter situations where you want to "skip the rest of the processing for the current loop and move immediately to the next iteration" only when a specific condition is met. Many oth... -
VBA樹林
[VBA] How to Add Line Breaks to Outlook Emails Cleanly (Loop Method)
Environment OS: Windows 10 Pro Software: Microsoft Excel VBA, Outlook Background When creating Outlook emails using VBA, I used to write & vbCrLf repeatedly to insert line breaks in the body text. However, this made the code very dif... -
VBA樹林
[VBA] How to Control Focus in UserForms (SetFocus and Enter Event)
In VBA UserForms, "focus" refers to the control that is currently active and ready to accept keyboard input. When a user opens a form, it is helpful if the cursor is already placed in the correct text box so they can start typing immedia... -
VBA樹林
[Excel VBA] How to Extract and Copy Only Specific Columns
Overview When processing Excel data, you often need to extract only specific columns instead of the entire dataset. While you can do this manually using filters or copy-paste, VBA allows you to automate the extraction of multiple columns... -
VBA樹林
[Excel VBA] How to Create a “Duplicate” Button to Copy Sheets Easily
Background When working in Excel, you often need to copy and reuse existing sheets. Previously, I would manually right-click the sheet tab and select "Move or Copy," but this process felt tedious. I wanted to automate it using VBA. In th... -
VBA樹林
[Excel VBA] How to Remove Empty Rows from a Table
This article explains how to efficiently delete empty rows from a table using VBA. Prerequisites This code is designed for the following conditions: Table Structure: The table exists on a single worksheet. Target Range: The rows to be de... -
VBA樹林
[Excel VBA] How to Extract Specific Elements from Microsoft Edge Using SeleniumBasic
Introduction Since Windows 10, automating Internet Explorer (IE) is no longer recommended, and scraping using Microsoft Edge has become the mainstream approach. This article explains how to use SeleniumBasic and EdgeDriver to access a sp... -
VBA樹林
[Excel VBA] How to Sort by 4 or More Columns with Priority (Multi-Key Sort Macro)
Overview This article explains how to create an Excel VBA macro that sorts data using 4 or more keys by utilizing the SortFields collection. While sorting by complex conditions manually takes time, using a macro allows you to reproduce t... -
VBA樹林
[Excel VBA] 4 Basic Patterns to Automate Printing (Sheet, Workbook, Range)
When creating routine reports or documents, manually selecting the same sheets or cell ranges to print every time is time-consuming. Using VBA, you can automate this process with a single "Print" button. This allows you to print specific... -
VBA樹林
[Excel VBA] How to Automatically Install an Excel Add-in (.xlam) Using a Macro
When distributing your own macros as an "Add-in (.xlam file)," asking users to manually install them can be difficult and requires detailed instructions. If you have a macro that automatically handles everything from installation to acti... -
VBA樹林
[Excel VBA] Basic Technique to Speed Up Processing by Loading Cell Ranges into a 2D Array
When processing large amounts of cell data in VBA, reading and writing cells one by one (using loops like For Each) can become extremely slow as the data volume increases. The most effective and basic way to solve this performance issue ... -
VBA樹林
[Excel VBA] How to Open and Control an Existing Workbook by File Path
When building VBA macros, you often need to perform operations across different workbooks. For example, you might want to open another Excel file to read data or write results to a separate file. This article explains the most basic and ... -
VBA樹林
[Excel VBA] How to Search for Exact Match Values Using the MATCH Function
When you want to search for a specific value in Excel table data, the MATCH function allows you to retrieve the relative row number of the corresponding cell. In this article, I will introduce how to use the MATCH function from VBA to se... -
VBA樹林
[Excel VBA] How to Get a List of Installed Printers on a PC
When creating print-related macros in VBA, it is often necessary to list currently available printer names or check if a specific printer is installed. By accessing Windows Shell functions from VBA, a list of printers registered on the P... -
VBA樹林
[Excel VBA] How to Insert Hyperlinks in Cells | External and Internal Link Settings
As part of improving business efficiency with Excel, many users wish to automate the process of setting hyperlinks in cells. In this article, I will carefully explain how to use VBA to insert links to external websites and links to other... -
VBA樹林
[Excel VBA] Two Ways to Switch Between Multiple Excel Workbooks
When creating macros that process data across multiple Excel files (workbooks)—such as "copying values from a data workbook to a summary workbook"—you must accurately switch the target workbook being operated on. There are two main metho... -
VBA樹林
[Excel VBA] How to Draw Cell Borders: All Borders vs. Outer Borders
In Excel, drawing borders on cells is a common task to make data easier to read. While you can do this manually with a mouse, using VBA is very effective for large ranges or repetitive tasks. In this article, I will introduce two pattern... -
VBA樹林
[Excel VBA] How to Get File and Folder Information Using FSO (GetFile, GetFolder)
The basis of file manipulation using the FileSystemObject (FSO) starts with getting the target file or folder as an "Object." By retrieving it as an object, you can easily access various information held by that file or folder, such as i... -
VBA樹林
[Excel VBA] How to Create a New Sheet with a Date and Color It
When working in Excel, you might want to automatically create a sheet with a specific date in its name and color it for better visibility. In this article, I will introduce how to easily achieve this using VBA. What We Will Achieve We wi... -
VBA樹林
[Excel VBA] How to Automatically Insert a Row When Entering Text
Introduction When handling duplicate data in Excel, you often want to "prioritize and retrieve values at the bottom" (which usually means the newest data). I previously used functions like MATCH or INDEX to retrieve values, but since the... -
VBA樹林
[Excel VBA] How to Extract Unique Data (Unique List) Using the UNIQUE Function
Creating a unique list by removing duplicate values from a data set is fundamental for data aggregation and analysis. Traditionally, it was common to use Collection or Dictionary objects in VBA to achieve this. However, in the latest ver...