這是我希望它出現的方式?請為此建議一個VBA代碼

Sub FormatTest()
With Sheets("Test")
With .Range("$B:$Z")
.FormatConditions.Add xlExpression, Formula1:="=mod(row(),2)=0"
With .FormatConditions(1).Borders(xlBottom)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
.FormatConditions(1).StopIfTrue = False
End With
End With
End Sub
uj5u.com熱心網友回復:
根據您的螢屏截圖,這似乎有效。如上所述,合并單元格通常是有問題的,應盡可能避免。
Sub FormatTest()
Dim c As Long, r As Range
With Sheets("Test")
For c = 1 To .Cells(1, Columns.Count).End(xlToLeft).Column
Set r = .Cells(1, c).MergeArea
With Union(.Cells(1, c), .Columns(r(r.Columns.Count).Column))
With .Borders(xlRight)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
End With
Next c
End With
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/339740.html
