|
这个就是两点:
1,用interior.colorindex >0 检查是否有底色;
2, 对第一格的结果进行部分加粗,用.Characters(Start:=9, Length:=1).Font;
下面代码供参考:
- Sub Format4U()
-
- Dim iRow, iColumn, il, ir As Integer
- Dim str As String
-
- iRow = Selection.Row
- iColumn = Selection.Column
-
- If Cells(iRow + 2, iColumn).Interior.ColorIndex > 0 Then
- str = Cells(iRow, iColumn).Value & "(" & Cells(iRow + 1, iColumn) & "/" & Cells(iRow + 2, iColumn) & ")"
-
- Else
- str = Cells(iRow, iColumn).Value & "(" & Cells(iRow + 1, iColumn) & ")"
-
- End If
-
- il = InStr(str, "(") + 1
- ir = InStr(str, ")")
- ActiveCell.Value = str
-
- Debug.Print "il=" & il & " ir=" & ir
-
- With ActiveCell.Characters(Start:=il, Length:=ir - il).Font
- .Name = "等线"
- .FontStyle = "加粗"
- .Size = 11
- .Strikethrough = False
- .Superscript = False
- .Subscript = False
- .OutlineFont = False
- .Shadow = False
- .Underline = xlUnderlineStyleNone
- .ThemeColor = xlThemeColorLight1
- .TintAndShade = 0
- .ThemeFont = xlThemeFontMinor
- End With
- End Su
复制代码
|
|