0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

EXCEL VBA 選択範囲を全角・半角変換するマクロを右クリックメニューに追加する&メニューのリセット

Last updated at Posted at 2019-02-13

Sub 半角変換()
Dim SR As Range
For Each SR In Selection
SR.Value = StrConv(SR.Value, vbNarrow)
Next SR
End Sub

Sub 全角変換()
Dim SR As Range
For Each SR In Selection
SR.Value = StrConv(SR.Value, vbWide)
Next SR
End Sub
Sub 右クリック()
With CommandBars("cell").Controls.Add(Type:=msoControlButton, before:=8) 'before=8は、右クリックメニューの上から8個目に「全角に変換」メニューを追加するという意味です。自分で調節してください
.Caption = "全角に変換"
.OnAction = "全角変換"
End With
With CommandBars("cell").Controls.Add(Type:=msoControlButton, before:=9) 'before=9も何行目に入れるかは自分で調節してください
.Caption = "半角に変換"
.OnAction = "半角変換"
End With

##右クリックメニューをリセットする
End Sub
Sub リセット()
CommandBars("cell").Reset

End Sub

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?