メインコンテンツへスキップ

Excelで特定のセルをクリックしたときにカレンダーをポップアップするにはどうすればよいですか?

ワークシートに列範囲があるとすると、内部で日付を頻繁に入力および変更する必要がありますが、時間ごとに手動で日付を入力または変更するのは退屈です。 列範囲を手動で入力せずに日付をすばやく入力するにはどうすればよいですか? この記事では、特定の範囲のセルをクリックするとカレンダーがポップアップし、カレンダーで日付を選択した後、選択したセルに日付が自動的に挿入されることについて説明しています。


VBAコードで特定のセルをクリックすると、カレンダーがポップアップ表示されます

この問題を次のように段階的に解決してください。

Note:この方法は、Microsoft Excel32ビットでのみ機能します。

ステップ1:カレンダーを使用してユーザーフォームを作成する

セルをクリックしてポップアップするカレンダーを含むユーザーフォームを作成してください。

1。 押す 他の + F11 キーを同時に開いて アプリケーション向け Microsoft Visual Basic 窓。

2。 の中に アプリケーション向け Microsoft Visual Basic ウィンドウ、クリック インセット > ユーザーフォーム.

3.次に、 ユーザーフォーム フォルダーとその下に ツールボックス ウィンドウがポップアップします。 ツールボックス、いずれかのコントロールをクリックして右クリックし、を選択します 追加のコントロール 右クリックメニューから。 スクリーンショットを参照してください:

4。 の中に 追加のコントロール ダイアログボックスで、下にスクロールして Microsoft MonthView コントロール 内のオプション 利用可能なコントロール ボックスをクリックし、 OK

5.次に、 月表示 ボタンがに追加されます ツールボックス 窓。 このMonthViewボタンをクリックしてから、UserForm1ウィンドウをクリックして、ユーザーフォームにカレンダーを作成してください。

Note:ユーザーフォームの境界線をドラッグすることで、挿入されたカレンダーに合わせてユーザーフォームウィンドウのサイズを調整できます。

6. UserForm1に挿入されたカレンダーをダブルクリックし、 Code ウィンドウで、元のコードを次のVBAスクリプトに置き換えてください。

VBA code: create a user form with calendar

Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
 On Error Resume Next
   Dim xRg As Object
   For Each xRg In Selection.Cells
      xRg.Value = DateClicked
   Next xRg 
   Unload Me
End Sub

Note:このコードは、カレンダーから日付を選択した後、選択したセルに日付を挿入するのに役立ちます。

ステップ2:セルをクリックしたときにカレンダーをアクティブにする

次に、クリックしたときにカレンダーをポップアップする特定のセルを指定する必要があります。 次のようにしてください。

7.クリックするセルを含むシート名をダブルクリックして、左側にカレンダーをポップアップします プロジェクト ペインで、以下のVBAコードをコピーして[コード]ウィンドウに貼り付けます。 スクリーンショットを参照してください:

VBA code: Click cell to pop up calendar

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If (Target.Count = 1) Then
    If Not Intersect(Target, Range("A2:A10")) Is Nothing Then UserForm1.Show
    End If
End Sub

Note:コードでは、A2:A10は、カレンダーをポップアップするためにクリックするセルです。 必要に応じてセル範囲を変更してください。

8。 押す 他の + Q キーを同時に閉じて アプリケーション向け Microsoft Visual Basic 窓。

これ以降、現在のワークシートで指定された範囲内のセルをクリックすると、以下のスクリーンショットのようにカレンダーがポップアップ表示されます。 また、カレンダーから日付を選択すると、選択したセルに日付が自動的に挿入されます。


VBAコードで特定のセルをクリックすると、カレンダーがポップアップ表示されます

このセクションでは、 日付ピッカー の有用性 Kutools for Excel。 この機能を有効にした後、日付セルをクリックするとカレンダーがポップアップします。既存の日付を新しい日付に簡単に置き換えることができます。 この機能を適用するには、以下の手順に従ってください。

1。 クリック クツール > コンテンツ > 日付ピッカーを有効にする.

2.この機能を有効にした後、日付セルをクリックすると、カレンダーアイコンがセルのすぐ横にポップアップ表示されます。

3.カレンダーアイコンをクリックして、 日付ピッカー ダイアログボックスをクリックし、新しい日付をクリックして、選択したセルの日付を置き換えます。

注意:

  • 元に戻すボタン:このボタンをクリックして、置換日付を元に戻します。
  • 閉じるボタン:このボタンをクリックして、[日付ピッカー]ダイアログボックスを閉じます。
  • この機能は、日付を含むセルにのみ適用できます。

  このユーティリティの無料トライアル(30日)が必要な場合は、 クリックしてダウンロードしてください、次に、上記の手順に従って操作を適用します。


関連記事:

最高のオフィス生産性向上ツール

🤖 Kutools AI アシスタント: 以下に基づいてデータ分析に革命をもたらします。 インテリジェントな実行   |  コードを生成  |  カスタム数式の作成  |  データを分析してグラフを生成する  |  Kutools関数を呼び出す...
人気の機能: 重複を検索、強調表示、または識別する   |  空白行を削除する   |  データを失わずに列またはセルを結合する   |   数式なしのラウンド ...
スーパールックアップ: 複数の基準の VLookup    複数の値の VLookup  |   複数のシートにわたる VLookup   |   ファジールックアップ ....
詳細ドロップダウン リスト: ドロップダウンリストを素早く作成する   |  依存関係のドロップダウン リスト   |  複数選択のドロップダウンリスト ....
列マネージャー: 特定の数の列を追加する  |  列の移動  |  Toggle 非表示列の表示ステータス  |  範囲と列の比較 ...
注目の機能: グリッドフォーカス   |  デザインビュー   |   ビッグフォーミュラバー    ワークブックとシートマネージャー   |  リソースライブラリ (自動テキスト)   |  日付ピッカー   |  ワークシートを組み合わせる   |  セルの暗号化/復号化    リストごとにメールを送信する   |  スーパーフィルター   |   特殊フィルター (太字/斜体/取り消し線をフィルター...) ...
上位 15 のツールセット12 テキスト ツール (テキストを追加, 文字を削除する、...)   |   50+ チャート 種類 (ガントチャート、...)   |   40+ 実用的 (誕生日に基づいて年齢を計算する、...)   |   19 挿入 ツール (QRコードを挿入, パスから画像を挿入、...)   |   12 変換 ツール (数字から言葉へ, 通貨の換算、...)   |   7 マージ&スプリット ツール (高度な結合行, 分割セル、...)   |   ... もっと

Kutools for Excel で Excel スキルを強化し、これまでにない効率を体験してください。 Kutools for Excelは、生産性を向上させ、時間を節約するための300以上の高度な機能を提供します。  最も必要な機能を入手するにはここをクリックしてください...

説明


Officeタブは、タブ付きのインターフェイスをOfficeにもたらし、作​​業をはるかに簡単にします

  • Word、Excel、PowerPointでタブ付きの編集と読み取りを有効にする、パブリッシャー、アクセス、Visioおよびプロジェクト。
  • 新しいウィンドウではなく、同じウィンドウの新しいタブで複数のドキュメントを開いて作成します。
  • 生産性を 50% 向上させ、毎日何百回もマウス クリックを減らすことができます!
Comments (18)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I am not seeing the Microsoft MonthView Control in the listing, but it may be as Pete (#32847) mentioned that this will not work in Office 365 or 64-bit Microsoft Office.
This comment was minimized by the moderator on the site
Hi Teagan Caudle,
I searched and tried the methods suggested in google, but ultimately could not register the MonthView control in Microsoft 365.
Sorry for the inconvenience. Maybe you can check this out.
https://social.technet.microsoft.com/Forums/Azure/en-US/db3b4dff-aad7-4d88-87cc-8f3f117be550/microsoft-windows-common-controls-60-for-office-2016
This comment was minimized by the moderator on the site
There is no Microsoft MonthView Control listed (Office 365), and the directions here doesn't explain how one would get that control, so this is pretty much useless unless you're using an older version of Excel.
This comment was minimized by the moderator on the site
The calendar will show up but when I click on the date, the cell doesn't populate
This comment was minimized by the moderator on the site
Hi,
The code works well in my case. Which Excel version are you using?
This comment was minimized by the moderator on the site
Thank you so much! These directions were super useful :)
This comment was minimized by the moderator on the site
Hi, Is it possible to put the date picker pop-up for multiple column, as in my sheet I have "start date", "end date" and "agreement date". if yes then how?
This comment was minimized by the moderator on the site
Hi jeet,
Follow the steps and replace the range "A2:A10" in the second VBA code with your column range (such as C2:E2).
This comment was minimized by the moderator on the site
Salve il codice funziona benissimo, ma se volessi farlo funzionare anche su un altro foglio
This comment was minimized by the moderator on the site
if i try to select a row, the pop up will activate and the date appears in each cell in that row


how can i avoid this
This comment was minimized by the moderator on the site
Hi Sam,
The code has been updated in the article with the problem solving. Please have a try and thank you for your comment.
This comment was minimized by the moderator on the site
tarihi seçebiliyorum ama a1:a10 hücrelerine seçtiğim tarih eklenmiyor. teşekkür ederim
This comment was minimized by the moderator on the site
Hello everyone,

Can anyone tell me how to popup a calendar in a range of cells, but starting only from the cell right bellow a table header and down bellow in an excel column.


Thank you in advance.
This comment was minimized by the moderator on the site
Use i.e: Range("B6:C30")
This comment was minimized by the moderator on the site
Good Day,
Sorry I didn't got your question. Would be nice if you could provide screenshot of what you are trying to do.
This comment was minimized by the moderator on the site
Use i.e: Range("B6:C30")
This comment was minimized by the moderator on the site
i used these VBA codes and everthing's fine so far. The range is A2:A10 and calendar pops up when you select a cell into it. But if you mark row from 2 to 10 again the calendar pops again. It's the same with column "A" if you mark it, again the calendar pops. How should i proceed, in order to get the calendar only in the range i've defined?
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations