1.點擊-索引標籤>開發人員>程式碼>Visual Basic;如下圖;

2.跳出Microsaft Visual Basi視窗,點擊-索引標籤>插入>模組;如下圖;

3.在工作區中輸入
Sub 跨欄置中()
' 快速鍵: Ctrl+d
'
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
End Sub
如下圖:
.4. 點擊-索引標籤>檢視>Microsoft Excel 或索引標籤下的Excel 圖示 或 Alt+F11;如下圖;

5.視窗跳至Excel -點擊-索引標籤>開發人員>程式碼>巨集;如下圖;

6.跳出巨集視窗,點擊選項;如下圖示:

7.輸入欲設定的快捷鍵,並按確定;如下圖:( 注意:不要與原Excel快捷鍵相衝突 )

8.視窗跳回巨集視窗,點擊執行;如下圖示:

9.框選合併範圍;按 Ctrl + d;如下圖示:

10.合併成功且置中;如下圖示:

11.新設置的快捷鍵並不會自動傳到每一個Excel檔案內,所以需另存新檔(樣板檔)。
參考:Excel 跨欄置中 有沒有快捷鍵呢?
12.可以跨欄置中,當然可以跨欄靠左與跨欄靠右
跨欄靠左 >>
Sub 跨欄靠左()
' 快速鍵: Ctrl+s
'
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
End Sub
跨欄靠右 >>
Sub 跨欄靠右()
' 快速鍵: Ctrl+s
'
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
End Sub
沒有留言:
張貼留言