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

Excelセルの中央に画像を配置する方法は?

この記事では、以下のスクリーンショットに示すように、Excelワークシートのセルの中央に画像を移動する方法を示します。

VBAコードを使用して画像をセルの中心に移動します


VBAコードを使用して画像をセルの中心に移動します.

Excelのワークシートのセルの中央に画像を移動するには、次のようにしてください。

1.セルの中央に配置する必要のある画像が含まれているワークシートを開き、を押します。 他の + F11 キーを押して アプリケーション向け Microsoft Visual Basic 窓。

2。 の中に アプリケーション向け Microsoft Visual Basic ウィンドウをクリックしてください インセット > モジュール。 次に、VBAコードをコピーして[コード]ウィンドウに貼り付けます。

VBAコード:ワークシートのセルの中心に画像を移動します

Sub CenterPictures()
With ActiveSheet.Shapes("Picture 2")
.Top = Range("A1").Top + (Range("A1").Height - .Height) / 2
.Left = Range("A1").Left + (Range("A1").Width - .Width) / 2
End With
With ActiveSheet.Shapes("Picture 4")
.Top = Range("A2").Top + (Range("A2").Height - .Height) / 2
.Left = Range("A2").Left + (Range("A2").Width - .Width) / 2
End With
With ActiveSheet.Shapes("Picture 6")
.Top = Range("A3").Top + (Range("A3").Height - .Height) / 2
.Left = Range("A3").Left + (Range("A3").Width - .Width) / 2
End With
End Sub

ノート:

1)。 コードでは、画像2がセルA1の中央に移動され、画像4がセルA2に移動され、画像6がセルA3に移動されます。
2)。 セルの中心に移動する必要があるその他の画像については、このコードをVBAコードに追加し、 画像名 & セルアドレス あなたの必要に基づいて。
With ActiveSheet.Shapes("Picture name")
.Top = Range("Cell Address").Top + (Range("Cell Address").Height - .Height) / 2
.Left = Range("Cell Address").Left + (Range("Cell Address").Width - .Width) / 2
End With

3。 プレス F5 コードを実行するためのキー。

次に、下のスクリーンショットに示すように、指定したすべての画像が特定のセルの中央にすぐに移動します。


関連記事:

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

🤖 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 (5)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi crystal,

Just an idea, how about to center a selected image or shape in a cell, so no need to manually type Picture Name and Cell Address in the code?

Thanks.
This comment was minimized by the moderator on the site
Is there a way to use this macro without having to use the Picture name? Perhaps using the file type such as a .jpg or .png?
This comment was minimized by the moderator on the site
Hi Elijah,
It is hard to match images to the corresponding cells using the file type only.
This comment was minimized by the moderator on the site
how do you know what picture number to use? I tried adding code for b1 - b3 but not sure what picture number to use?
This comment was minimized by the moderator on the site
Hi Jeff,
Sorry for the inconvenience.
When selecting a picture, the picture number will be displayed on the Name box in Excel. It is the picture name in the workbook. See the attached image.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations