我有麻煩圖表中格式化列以匹配特定的字體,顏色,取向等Excel VBA中列在圖表 - 格式字體,顏色,取向等
該代碼,而集中在柱A:它適用於工作表中的每個單元格。我只希望它影響列A:
Sub PGMNumber()
'
' PGMNumber Macro
'
'
Range("A:A").Select
With Selection.Font
.Name = "Arial"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.Color = -16776961
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection.Font
.Name = "Arial"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.Color = -16776961
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Selection.Font.Bold = False
Selection.Font.Bold = True
With Selection.Font
.Color = -10477568
.TintAndShade = 0
End With
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("A:A").ColumnWidth = 9.43
End Sub
這是通過記錄我的步驟完成的。我需要的只是FontName,Color,Bold,Size和Alignment。刪除的內容,我不需要休息的代碼:(
人可以幫我簡化代碼,以便它只會影響A列?
此外,如何添加的選項包括其他列,例如B,C,d等
最後,我可以有宏開始從A6格式化向下,向下B6,C6向下,等?這樣的圖的頭保持不變。
謝謝!
這完美地工作!現在如果我想讓這個宏的格式一次多於一列,該怎麼辦?我在哪裏輸入第二欄的代碼?具體是B列......謝謝泰勒! @Taylor – BMRobin
如果列都彼此相鄰,在.Range第二個「A」改爲你所需要的最後一列,例如'.Range(「A6:d」&...' – Toast
如果問題得以解決,請註明答案接受 – Toast