修改為行框不要列框,並在取消邊框時只取消掉邊框顔色
时间: 2023-08-11 21:26:32 浏览: 34
好的,根据您的要求,以下是修改后的VBA代码,将行框设为红色粗线条,取消边框时只取消掉边框颜色:
```VBA
Sub HighlightTodayAndTomorrow()
Dim todayDate As Date
Dim tomorrowDate As Date
Dim lastRow As Long
Dim i As Long
todayDate = Date
tomorrowDate = Date + 1
lastRow = Range("a1").CurrentRegion.Rows.Count
For i = 1 To lastRow
If Cells(i, 1).Value = todayDate Or Cells(i, 1).Value = tomorrowDate Then
Rows(i).Borders(xlEdgeTop).LineStyle = xlContinuous '将符合条件的行边框设为实线
Rows(i).Borders(xlEdgeTop).Weight = xlThick '将符合条件的行边框粗细设为粗线
Rows(i).Borders(xlEdgeTop).Color = RGB(255, 0, 0) '将符合条件的行边框颜色设为红色
Else
Rows(i).Borders(xlEdgeTop).ColorIndex = xlNone '仅取消边框颜色
End If
Next i
End Sub
```
这段代码将行框设为红色粗线条,同时取消边框时只取消边框颜色,而不是取消整个边框。边框线条的位置可通过 `xlEdgeTop` 等参数进行调整,详细信息请参考 Microsoft 官方文档。