mori– Author –
-
VBA樹林
[VBA] How to Save UserForm Input Values as History | Auto-Save Date and Time
Background When creating a UserForm with VBA in Excel, you often encounter situations where you want to "keep a record of what was entered in the form." For example, when someone registers data using a form, it is useful to automatically... -
VBA樹林
[Excel VBA] Two Ways to Get a Filename Without Extension (Split / InStrRev)
Introduction When handling files in VBA, you frequently encounter situations where you need to remove the extension (e.g., .xlsx) from a full filename (e.g., Report.xlsx) to get just the base name (Report). This is common when creating n... -
VBA樹林
[Excel VBA] How to Read XML Files: Extracting Nodes to Sheets Using DOM Objects
Introduction XML files are frequently used for data integration between systems and for configuration files. There are often cases where you need to read this XML data in Excel and list it on a sheet. In this article, I will introduce ho... -
VBA樹林
[Excel VBA] How to Identify the Selected Option Button on a Worksheet
Introduction When you want users to select only one item from multiple choices on an Excel sheet, "Option Buttons" (Form Controls) are the ideal tool. They are perfect for questionnaires or settings sheets where choices must be mutually ... -
VBA樹林
[Excel VBA] Basic Code to Connect to Access Database (Using DAO)
Introduction To connect to and manipulate an Access database (.accdb) directly from Excel VBA, it is common to use DAO (Data Access Objects). This method establishes the connection required to reference tables/queries or write data to Ac... -
VBA樹林
[VBA] How to Randomly Select Names and Place Them in Cells (No Duplicates)
Excel VBA allows you to easily automate the process of randomly extracting items from a specified name list and placing them into cells. This article introduces the procedure and VBA code for extracting random names without duplicates an... -
VBA樹林
[Excel VBA] How to Copy Existing Worksheets (.Copy)
Introduction In tasks like creating monthly reports, you often need to duplicate a "Template" sheet that already contains the correct formatting and formulas. While copying a sheet manually is simple, using VBA allows you to completely a... -
VBA樹林
[VBA] How to Preview Email Content in Outlook Before Sending
Environment OS: Windows 10 Pro Software: Microsoft Outlook, Excel VBA Background While automating email distribution using VBA is efficient, there are many cases where you might want to double-check the "To" or "CC" fields—especially whe... -
VBA樹林
[Excel VBA] How to Export a Specific Cell Range as a CSV File
When managing data in Excel, you often need to save only a specific range as a CSV file. Manually selecting the range, copying it to a new workbook, and saving it as a CSV every time is a tedious process. This article explains how to use... -
VBA樹林
[Excel VBA] Complete Guide to Associative Arrays: How to Use Scripting.Dictionary
Standard VBA arrays manage data using numeric indices, such as myArray(0). However, there are many situations where you want to handle data using strings as keys—for example, retrieving a "Price" using a "Product Name" as the key. This m... -
VBA樹林
[Excel VBA] How to Protect Your Source Code (Setting a Project Password)
When sharing Excel files with macros, you may want to prevent others from viewing or accidentally editing your source code. To achieve this, you can lock the VBA project with a password. By setting this protection, the code becomes inacc... -
VBA樹林
[Excel VBA] How to Automatically Export Charts and Tables to PowerPoint
When creating reports, you often need to transfer charts and tables from Excel to PowerPoint. Doing this manually for multiple slides is time-consuming. This article provides a VBA macro that automates the process of opening PowerPoint, ... -
VBA樹林
[Excel VBA] Mastering Checkbox Properties on Sheets: Caption and Value
Checkboxes in Excel's "Form Controls" are essential UI (User Interface) elements for confirming task completion or toggling options on and off. To control these via VBA, understanding their basic properties is crucial. This article expla... -
VBA樹林
[Excel VBA] How to Create and Write to a Text File (.txt) Using FSO
In VBA macros, it is common to output results as a simple text file (.txt) rather than in Excel format, especially when integrating with other systems. Using the FileSystemObject (FSO), you can create new text files and write content to ... -
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...