VBA樹林– category –
-
VBA樹林
[VBA] How to Define Methods (Sub/Function) in a Class
Introduction A VBA Class Module is a blueprint for an "Object" that combines data (Properties) and the processing to manipulate that data (Methods). While properties represent the "state" of an object, methods define the object's "behavi... -
VBA樹林
[VBA] High-Precision Time Measurement in Milliseconds (GetTickCount API)
Introduction The VBA Timer function is useful for easily measuring processing time in seconds. However, if you want to compare the performance of processes that complete very quickly, the Timer function's precision is often insufficient.... -
VBA樹林
[Excel VBA] How to Force Recalculation Before Saving Even in Manual Calculation Mode
In heavy Excel files containing a large number of formulas, users often set the calculation method to "Manual" to make operations smoother. However, this setting carries a significant risk: "forgetting to recalculate (F9 key) and saving ... -
VBA樹林
[Excel VBA] How to Add New Records to a Table | Using ListObject.ListRows.Add
Excel Tables (ListObject) are very convenient as structured data. Understanding how to add records (rows) using VBA is incredibly helpful for automating data entry tasks. In this article, I will explain how to add the "next record" to a ... -
VBA樹林
【VBA】外部ファイルからデータをランダムに取得する方法|サンプル抽出の自動化
経緯 Excel VBA(Visual Basic for Applications)は、日々の作業を効率化するための強力なツールです。 今回は、「外部のExcelファイルを開き、そこからランダムにデータを取得して、現在作業中のシートに反映させる方法」をご紹介します。 この技術は、... -
VBA樹林
[VBA] How to Retrieve Specific Pivot Table Values (GetPivotData)
Overview In Excel Pivot Tables, you often encounter situations where you want to automatically retrieve only the aggregated results that match specific conditions. The GetPivotData function is very useful for this purpose. In this articl... -
VBA樹林
[VBA] Simplify Column Processing with Loops: How to Shorten Formula Copying Code
Introduction When writing Excel VBA, if you repeat similar processes, the code can become very long, making it difficult to manage and modify. In this article, I will introduce how to rewrite "code that performs the same process (copying... -
VBA樹林
[PowerPoint VBA] How to Open an Excel File and List All Charts
Background When using VBA to automate tasks in PowerPoint, I encountered a requirement: "I want to open an external Excel file and retrieve a list of all charts contained within it." To achieve this, I wrote a code that controls Excel fr... -
VBA樹林
[Excel VBA] How to Auto-Set Table Formulas Using Structured References ([@ColumnName])
In Excel Tables (ListObject), using "Structured References" allows you to set formulas that automatically apply calculations to every row. You can also use this feature from VBA to apply formulas like =[@Price]*[@Quantity] to an entire t... -
VBA樹林
[VBA] How to Scroll a Specific Cell to the Top-Left of the Screen
When working in Excel, there are times when you want to display a specific cell exactly at the top-left corner of the screen. For example, you might want to instantly jump to a row in the middle of a data list and start working from ther... -
VBA樹林
[VBA] Implementing the Quick Sort Algorithm: How to Sort Arrays Fast
Introduction When sorting arrays containing a large amount of data in VBA, processing speed becomes a critical factor. Among the many sorting algorithms available, Quick Sort is known as one of the fastest, as its name suggests. Quick So... -
VBA樹林
[VBA] How to Make Function Arguments Optional (The Optional Keyword)
Introduction When creating custom VBA functions, you may want to make them more flexible by allowing certain arguments to be omitted. For example, you might have a value that is usually the same (a default), but you want the option to ch... -
VBA樹林
[Excel VBA] How to Bulk Create Sequential Worksheets Using For Loops
Introduction Manually preparing 12 sheets for monthly reports (e.g., "April", "May"...) or separate summary sheets for each branch (e.g., "Branch01", "Branch02"...) can be very tedious. By combining the VBA For...Next loop with the Works... -
VBA樹林
[Excel VBA] Fast Counting of Partial Matches Using COUNTIF and Wildcards
When analyzing survey results, you often need to count the number of cells that contain a specific text (partial match), such as "How many answers include the word 'Tokyo'?". While you can achieve this using a For loop and the Like opera... -
VBA樹林
[Excel VBA] The Ultimate Technique to Speed Up Print Settings (PrintCommunication)
Have you ever felt that your macro runs surprisingly slowly when changing PageSetup settings, such as the print area, paper orientation, or margins? This slowness is particularly noticeable when using a network printer. The reason for th... -
VBA樹林
[VBA] How to Pass Arguments to Subroutines: Basics for Writing Reusable Code
Introduction Splitting VBA processing into subroutines (modularized macros) helps organize your code. However, if you leave them as is, they can only execute processing on "specific cell ranges" or "fixed text strings." To turn a subrout... -
VBA樹林
[VBA Beginners] Summary of Methods to Find the Next Available Row for Data Entry
There are many situations where you want to automatically write data to the next blank row in Excel. Adding new information to the end of existing data is a standard task in business automation. In this article, I will introduce multiple... -
VBA樹林
[VBA] How to Select a Folder Using a Dialog Box
Introduction I was creating a VBA program to create a folder and save Excel files inside it. Initially, I fixed the folder path directly in the code. However, I realized that the destination folder might change each time I run the progra... -
VBA樹林
[VBA] How to Extract Column D from Multiple Excel Files into a List (Batch Processing)
Background In my daily work, I often encounter situations where I need to summarize common items contained in multiple Excel files. Specifically, I wanted to collect data from Column D (the 4th column) of every file and combine it into a... -
VBA樹林
[Excel VBA] How to Show the “Open File” Dialog and Get the File Path (GetOpenFilename)
When reading external Excel files in macros, you often want the user to select the file manually instead of writing the file path directly in the code (hardcoding). By using the Application.GetOpenFilename method in VBA, you can easily d... -
VBA樹林
[VBA] How to Split Strings and Extract Values using the Split Function
Background Imagine a situation where a single cell in Excel contains multiple pieces of information in one line, such as "Soccer, August 1, 8:00 PM, School Ground". I wanted to find a way to break this text down into individual parts (Ev... -
VBA樹林
[VBA] How to Display Input Guides with Popups: Mastering InputMessage
Introduction Excel has a "Data Validation" feature that allows you to specify rules for values entered into cells. You can also use this feature to display a popup hint to the user when they select a cell. In this article, I will introdu... -
VBA樹林
[VBA] How to Modify and Reformat ListBox Values with a Macro
Introduction When displaying a table from a sheet in a UserForm ListBox, you often want to format the displayed content. For example, you might want to "zero-pad numbers in a specific column to 3 digits" or "add a specific string after a... -
VBA樹林
[Excel VBA] How to Read and Write Workbook Properties
Excel files store additional information (metadata) such as the author, title, subject, and creation date in their "Properties." You can usually check this information via the File > Info screen. However, by using VBA, you can automat... -
VBA樹林
[Excel VBA] How to Create an Empty XML File with an XML Declaration
Sometimes, you may need to generate an XML file from scratch using VBA, for example, when creating data to integrate with external systems. The first step in creating a well-formed XML document is to write the "XML Declaration" at the be... -
VBA樹林
[VBA] How to Share Variables Between Modules: Using Global Variables
Background When organizing Excel VBA code into multiple modules, I encountered a situation where I wanted to use a variable obtained in Module 1 for processing in Module 2. Specifically, I used the Call statement to run a subroutine in a... -
VBA樹林
[VBA] How to Automatically Fill a Name List in a Word Table (Looping)
I created a VBA script to automatically assign names to a schedule table created in Word. This code automates the repetitive task of manually typing the same names over and over again. What I Want to Achieve Automatically list names in t... -
VBA樹林
[VBA] How to Set Default (Enter) and Cancel (Esc) Buttons in UserForms
Introduction In standard Windows dialog boxes, pressing the Enter key acts as clicking "OK," and pressing the Esc key acts as clicking "Cancel." This behavior is intuitive for users and significantly improves the efficiency of keyboard o... -
VBA樹林
[VBA] How to Automatically Adjust Row Height and Column Width
Overview When working in Excel, the width of columns or the height of rows often does not match the input data, causing text to be cut off. Manually adjusting these one by one can be very time-consuming, especially when dealing with a la... -
VBA樹林
[VBA] How to Fix Cut and Paste Issues
Introduction In this article, I will share the correct method to "Cut" and "Paste" data using VBA. I attempted to create a process to cut a range of cells in Excel and paste them into a different location. Initially, the code did not wor...