VBA– tag –
-
VBA樹林
[Excel VBA] Change Cell Color to Yellow with “F9” and Red with “F10”
Background Previously, I created a tool where "pressing the F9 key runs code within a specific cell range." This time, I tried to expand functionality to support both the F9 and F10 keys. Specifications Target Range: Cells S1:S3. F9 Key:... -
VBA樹林
[Excel VBA] How to Automatically Record Save History | Log Who Saved When
When sharing Excel files, issues often arise where it is unclear "who saved the file and when" or "who is responsible for an entry error." To prevent such troubles, it is recommended to implement a system that automatically records the s... -
VBA樹林
[VBA] How to Centralize Common Logic for Multiple Sheets in ThisWorkbook | Avoid Writing Code for Each Sheet
Background While creating VBA programs in Excel, I often found it inconvenient to write the same code repeatedly for multiple sheets. Duplicate code leads to poor maintainability. Every time specifications change, code in all sheets must... -
VBA樹林
[Excel VBA] How to Automatically Move to Cell A1 When Opening a File (Using ThisWorkbook)
Introduction "When you show an Excel file to someone, always make sure it opens at cell A1." Have you ever been given this rule by a supervisor? It is a common courtesy in business to ensure files look neat immediately upon opening. Howe... -
VBA樹林
[PowerPoint] How to Execute Macros from the Ribbon Using Custom UI Editor
Background When creating tools with PowerPoint VBA, placing buttons directly on slides can look unpolished. Adding a custom tab to the Ribbon (header area) provides a seamless, application-like experience. This article summarizes how to ... -
VBA樹林
[VBA] How to Randomly Select a Cell and Input a Value
Background While developing a tool in VBA, I encountered a situation where I needed to "randomly select one cell from a list and input a value into it." I realized this could be applied to creating seating charts or random assignment tas... -
VBA樹林
[Word VBA] How to Automatically Insert Today’s Date on the Second Line | Right-Aligned “Update Date”
When creating documents in Word, do you ever find it tedious to manually type the date, such as "Update Date," every time? In this article, I will introduce a method using Word VBA to automatically insert today's date in the format "Upda... -
VBA樹林
[Excel VBA] How to Create a Dashboard That Displays Graphs on Button Click
When summarizing information visually in Excel, it is very convenient to have a "dashboard where charts appear when a button is pressed." In this article, I will introduce a method using VBA to copy charts from another sheet and display ... -
VBA樹林
[Excel VBA] Macro to Automatically Print a Specific Sheet (Printing Sheet1)
Background I often encounter situations where I need to print specific Excel files regularly. Thinking, "It would be convenient to print with a single click without opening the print settings every time," I wrote a VBA macro to automatic... -
VBA樹林
[Excel VBA] How to Prevent Actions When a Cell Value Exceeds a Limit
Overview I am using Excel VBA to manage inventory. We had a rule: "Report if the total weight goes over 30g." However, this rule was often ignored, causing problems. So, I decided to enforce it with a system: "If the total is over 30g, d... -
VBA樹林
[Excel VBA] How to Delete All Charts on a Specific Sheet (Using ChartObjects)
Background When creating multiple charts on an Excel sheet, you may encounter situations where you want to delete them all at once. In my case, I had a sheet serving as a "Dashboard" with many charts placed on it. Since deleting every ch... -
VBA樹林
[VBA] How to Split Strings by Colon to Extract Specific Data (Reading Dates from CSV)
Background When processing external CSV files, you often need to extract only a specific part of a text string contained in a cell. For example, if cell A1 of a CSV file contains the string "Date:20240831", you might want to retrieve onl... -
VBA樹林
[PowerPoint VBA] How to Open an Excel File Selection Dialog from a UserForm
Background When building tools in PowerPoint VBA, there is often a need to "open a dialog to select an Excel file using a UserForm." Instead of asking users to type a file path manually, allowing them to select it via a file dialog is mo... -
VBA樹林
[VBA] How to Jump to a Specific Cell by Pressing “F9” Within a Specific Range
Background A colleague asked me for a specific feature: "When the cursor is between cells F9 and F16, I want the cursor to jump to J7 when I press a specific key." I implemented this using VBA. In this example, I used the F9 key as the t... -
VBA樹林
[Excel VBA] Tired of Enabling Macros Every Time? How to Auto-Enable Them Safely
Background Every time I open a macro-enabled Excel file (.xlsm), a message bar appears asking, "Enable Content?" If you use macros daily, clicking this button every single time can become annoying. I decided to summarize how to set macro... -
VBA樹林
[VBA] How to Turn Off Option Buttons by Default in a UserForm
Introduction In this post, I will share how to set Option Buttons (also known as Radio Buttons) on a UserForm to be unselected (OFF) by default. Environment: OS: Windows 10 Pro Version: 20H2 Background I placed two option buttons, "Yes" ... -
VBA樹林
[VBA] How to Get a Value from a Word Table and Search for It in Excel using InStr
Background Unlike Excel, Word does not have the concept of cell addresses like "A1" or "F6". Therefore, I investigated how to extract data from a specific position in a Word table and search for that data within an Excel file. I achieved... -
VBA樹林
[Word × VBA] Macros Can Be Used in Word Too! A Detailed Guide on Recording and Running Macros
Introduction It is a common misconception that VBA (Macros) is exclusive to Excel. In reality, Microsoft Word also features a "Developer" tab and supports VBA functionality. By utilizing Word VBA, you can automate repetitive tasks and st... -
VBA樹林
[PowerPoint VBA] How to Display a Message Box Listing Shape Names and Types
Background I am currently working with PowerPoint VBA. I wanted to create a feature that "displays a message box listing the name and type of every shape on a slide." Here is the solution I implemented. The Code Below is the VBA code. Th... -
VBA樹林
[Excel VBA] How to Bulk Add Values to a ComboBox | Reading from a Cell Range
Background When setting up a pulldown menu (ComboBox) on a UserForm, adding multiple options manually can be tedious. Previously, I used to repeat the .AddItem method for every single item like this: ComboBox1.AddItem "Tokyo" ComboBox1.A... -
VBA樹林
[Excel VBA] Macro to Open a CSV File When a Cell is Selected | Linking Column G Selection to Filenames in Column E
Overview When working in Excel, there are times when you want to automatically open a related file just by selecting a specific cell. In this article, I will introduce a VBA macro that "automatically opens a corresponding CSV file when y... -
VBA樹林
【VBA】外部ファイルからデータをランダムに取得する方法|サンプル抽出の自動化
経緯 Excel VBA(Visual Basic for Applications)は、日々の作業を効率化するための強力なツールです。 今回は、「外部のExcelファイルを開き、そこからランダムにデータを取得して、現在作業中のシートに反映させる方法」をご紹介します。 この技術は、... -
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樹林
[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樹林
[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 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 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...