諸事情あり Excel for Mac 2016 を使っているが、どうやら、2011版と違い、ショートカットキーのユーザー設定ができない (ようだ)。困った。
ただ、いろいろなボタンを押してもがいていると、マクロにはショートカットキーを当てられるとわかったので、これで代用している。ということで、しばしば使う命令をマクロで書いてみた。下の方にスクリプトを載せておきましたので、もしも役に立つ方がいらっしゃったら、ぜひご利用ください。
- *なお、スクリプトは、「個人用マクロブック」に保存します。そうすると、どのファイルにおいても、上記のコマンドを利用することができます。個人用マクロブックの作成方法などについては All About のこちらの記事 が分かりやすいです。
- *スクリプトを書いたら、[ツール/マクロ.../オプション...] をクリックします。そうすると、ショートカットキーを設定できます。
- MyHeight・・・行の高さを変更
- MyMerge・・・セルの結合/結合を解除
- MyPrintAreaSetUp・・・選択された部分を印刷範囲として設定
- MyCenter・・・選択範囲で文字列を中央ぞろえ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub MyHeight() 'Define the height of the row(=tate) of the selected cell. | |
Dim tate_now As Single | |
tate_now = Selection.RowHeight | |
tate_now = tate_now / Application.CentimetersToPoints(1) | |
Dim tate As String | |
tate = InputBox("Type Height (cm).", "Set Height", tate_now) | |
'実行 | |
If tate <> "" Then | |
Selection.RowHeight = Application.CentimetersToPoints(CSng(tate)) | |
End If | |
End Sub | |
Sub MyMerge() 'Merge/Unmerge cells | |
Selection.MergeCells = Not Selection.MergeCells | |
End Sub | |
Sub MyPrintAreaSetUp() 'Set Selected Area as the Print Area | |
Dim hani As Range | |
Set hani = Selection | |
ActiveSheet.PageSetup.PrintArea = hani.Address | |
End Sub | |
Sub MyCenter() 'Sentaku_hani_de_chuou | |
With Selection | |
.HorizontalAlignment = xlCenterAcrossSelection | |
.VerticalAlignment = xlBottom | |
.WrapText = False | |
.Orientation = 0 | |
.AddIndent = False | |
.ShrinkToFit = False | |
.MergeCells = False | |
End With | |
End Sub |
0 件のコメント:
コメントを投稿