[Mac][Excel] Excel for Mac 2016 でマクロを使って、ショートカットキーのユーザー設定の代用にする

諸事情あり Excel for Mac 2016 を使っているが、どうやら、2011版と違い、ショートカットキーのユーザー設定ができない (ようだ)。困った。

ただ、いろいろなボタンを押してもがいていると、マクロにはショートカットキーを当てられるとわかったので、これで代用している。ということで、しばしば使う命令をマクロで書いてみた。下の方にスクリプトを載せておきましたので、もしも役に立つ方がいらっしゃったら、ぜひご利用ください。


  • *なお、スクリプトは、「個人用マクロブック」に保存します。そうすると、どのファイルにおいても、上記のコマンドを利用することができます。個人用マクロブックの作成方法などについては All About のこちらの記事 が分かりやすいです。

  • *スクリプトを書いたら、[ツール/マクロ.../オプション...] をクリックします。そうすると、ショートカットキーを設定できます。

  • MyHeight・・・行の高さを変更
  • MyMerge・・・セルの結合/結合を解除
  • MyPrintAreaSetUp・・・選択された部分を印刷範囲として設定
  • MyCenter・・・選択範囲で文字列を中央ぞろえ


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
view raw MyShortcut.xlsm hosted with ❤ by GitHub



0 件のコメント:

コメントを投稿

[Car] クイック板金(2回目)

車のバンパーを擦ってしまった。。。ということで、 イエローハットのクイック板金 にお願いしていました。別の店舗に持って行っての作業ということで数日かかりましたが、無事に車が帰ってきました。結果、とても綺麗に直してもらい、非常に満足しています。板金をしたと言われても、素人目にはわか...