VBA– tag –
-
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... -
VBA樹林
[Excel VBA Beginners] How to Change Cell Font Color | Specifying Colors with RGB
Introduction Have you ever wanted to change the text color of a specific cell using Excel VBA? Changing the font color to red or blue based on conditions improves visibility and helps with data visualization. In this article, I will intr... -
VBA樹林
[VBA] How to Convert Full-Width to Half-Width Characters | Using StrConv and vbNarrow
Environment OS: Windows 10 Pro (Version: 20H2) Software: Microsoft Excel VBA Background When processing values read from a barcode reader using VBA, I encountered a significant issue where the input was being interpreted as Full-Width (Z... -
VBA樹林
[VBA Beginners] How to Check if a String Contains Specific Text (Using InStr)
Introduction In Excel VBA, a very common task is checking whether a specific word or phrase exists within a string. For example, you might want to execute a process only if a cell contains the word "Urgent". In this article, I will intro... -
VBA樹林
[Excel VBA] How to Protect and Unprotect Worksheets
Introduction I wanted to automate the process of protecting and unprotecting sheets using VBA, so I learned how to do it. Solution: Use Protect and Unprotect In Excel VBA, you can protect or unprotect a sheet with a single line of code. ... -
VBA樹林
[VBA] How to Change the Outline Color of a Shape (AutoShape)
Introduction In this article, I will share how to change the outline (border) color of a shape using VBA. I previously learned how to change the fill color, but I also wanted to customize the line color to suit my design. Here is the met... -
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 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 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樹林
[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樹林
[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樹林
[VBA] How to Lock and Unlock Cells: Using the Locked Property
I recently wanted to lock only specific cells using VBA, so I learned the method for locking and unlocking cells programmatically. Solution: Using the Locked Property In Excel VBA, you can control whether cells are locked (editing prohib... -
VBA樹林
[VBA] How to Set the Initial Folder for File Dialog Boxes (ChDrive and ChDir)
When using a dialog box to select files in VBA, it can be very tedious to manually navigate to deep folder hierarchies if the initial folder is not set correctly. This article explains how to specify the folder that appears first when a ... -
VBA樹林
Excel VBAで表の列を同じ値ごとに結合する方法
Excelでデータを整理する際、同じ文字が連続しているセルをまとめて見やすくするために「セルの結合」が役立つ場合があります。本記事では、VBAを使って列内の同じ値を持つセルを自動的に結合する方法を解説します。 前提条件 このコードを利用するための... -
VBA樹林
Excel VBAで表から’-‘だけの列を削除する方法
Excelのデータ整理において、データが'-'で埋め尽くされた列は不要なことがよくあります。このような列を自動で削除する方法をVBAを使って簡単に実現する方法を解説します。 前提条件 このコードを利用する前提条件は以下の通りです。 表の範囲: 削除対象... -
VBA樹林
Excel VBAで表から空白行を削除する方法
Excelでデータを整理する際、空白の行が含まれると効率的な作業が妨げられることがあります。この記事では、1つの表に対してVBAを使い、空白行を効率的に削除する方法を解説します。 前提条件 以下の条件でコードを使用できます。 表の構造: 表が1つのシー... -
VBA樹林
Excel VBAで日付付きの新しいシートを作成し、色をつける方法
Excelで作業を進める中で、特定の日付付きのシートを自動で作成し、見やすく色をつける機能が欲しいと思ったことはありませんか?この記事では、VBAを使ってこれを簡単に実現する方法を紹介します。 実現すること 以下の3つを自動化します。 今日の日付を... -
VBA樹林
Excel VBAで印刷設定を一発で完了!コード解説付き
Excelで作成したシートを印刷する際、「1ページに収めたい」「縦向きにしたい」「A4サイズに設定したい」といった要望はありませんか?手作業でこれらの設定をするのは手間ですが、VBAを使えばワンクリックで完了できます。 今回は、印刷設定に特化したシ... -
VBA樹林
Excel VBAでテーブルの値を検索する方法【VBA】
Excel VBAを使って、指定した条件に一致するセルをテーブルから検索し、その値を利用する方法を紹介します。この手順により、大量のデータを含むテーブルから、特定の条件を満たすデータを効率的に抽出できるようになります。 1. 準備するもの テーブル: ... -
VBA樹林
Excel VBAで番号に対応した画像を自動挿入&ボタンを残して図形を削除する方法【VBA】
Excel VBAを使って、フォルダ内の画像を番号に対応した図形に自動で挿入するマクロと、指定したボタンだけを残してシート内の図形を一括で削除するマクロを紹介します。このコードを利用すれば、画像の配置やシート整理がより簡単に行えます。 1. 画像ファ... -
VBA樹林
Excel VBAで画像を自動配置&リセットする方法【VBA】
Excel VBAを使って、フォルダ内の画像をセルに自動配置するマクロと、配置した画像をワンクリックで削除するマクロを作成してみましょう。これらのコードを使えば、Excelシート上に手軽に画像を配置し、不要になったら簡単に削除できるようになります。 準... -
VBA樹林
Excel VBAでプルダウンリストに常に候補リスト全体を表示する方法【VBA】
Excelでデータ入力を簡単にするために、プルダウンリストを設定することは多くの方が利用しています。しかし、プルダウンリストで「一度選択するとリストが部分的にしか表示されなくなる」という問題に悩むことも多いのではないでしょうか? 本記事では、V... -
VBA樹林
Excel VBAでユーザーフォームからグラフ範囲を動的に変更する方法【VBA】
Excel VBAでグラフの範囲を動的に変更するために、ユーザーフォームを活用してみましょう。この記事では、2つのテキストボックスを使って範囲の開始行と終了行を指定し、「更新」ボタンをクリックすることでグラフの表示範囲が変更できるようにする方法を... -
VBA樹林
Excelの「ドキュメント検査」機能とは?プロパティと個人情報の削除方法とメリット・デメリット【Excel】
こんにちは!今回は、Excelでファイルを保存するときに表示される「ドキュメント検査機能では削除できない個人情報がドキュメントに含まれていることがありますので、ご注意ください」というメッセージについて解説します。このメッセージを目にした方も多... -
VBA樹林
【VBA】他人にコードを見られたくないときの対処法|VBAプロジェクトにパスワードを設定する方法
経緯 業務で使用しているExcelファイルにVBAマクロを組み込んでいる中で、「VBAのコードを他人に見られたくない」「勝手に編集されると困る」と感じる場面がありました。 そこで、VBAプロジェクトにパスワードを設定してロックする方法を実行しました。こ... -
VBA樹林
【VBA】文字列を「:」で区切って特定の情報を抽出するマクロ|CSVファイルから日付だけを取得
経緯 外部のCSVファイルを読み込んで処理を行う中で、セルに含まれている文字列から一部の情報だけを抽出したいという場面がありました。具体的には、CSVファイルのA1セルに「日付:20240831」という文字列が入っており、そこから**「20240831」だけを取得... -
VBA樹林
【VBA】Excelの特定シートを自動で印刷するマクロ|Sheet1を印刷
経緯 Excelファイルで定期的に印刷が必要な場面があり、「いちいち印刷設定を開かずに、ワンクリックで印刷できたら便利だ」と思い、VBAでSheet1を自動印刷するマクロを書いてみました。 実行後の仕様 このマクロを実行すると、次のように動作します。 Exc... -
VBA樹林
【VBA】Excelで弁当注文を締め切るマクロ|日付を自動ロック
経緯 Excelで管理している弁当の注文ファイルにおいて、「ある時刻になったら、翌日の注文欄を入力できないようにしたい」というニーズがありました。 これまでは手作業でロックしていたのですが、VBAを使って自動的に明日の日付の列を保護するコードを作... -
VBA樹林
セルの中が「30」以上になったら、書き込みができないようにしたい
概要 Excel VBAを使って、棚卸をしています。「30g以上になったら、報告する」というルールでしたが、守られておらず、困ったので、 いっそのこと「30gになってたら、記入させない」ということにしました。 Excelの構成 A列に品名B列に数C列にgE1セルにgの... -
VBA樹林
Excel VBAで遭遇する一般的なエラーとその対処方法
概要 Excel VBAを使ってプログラムを開発していると、様々なエラーに遭遇することがあります。この記事では、実際に経験したエラーについて、原因とエラーの説明、対処方法を紹介します。 実行時エラー 1004: Copyメソッド の失敗 原因とエラーの説明: こ...