我不能让它完全消失,但我可以很好地隐藏它。我从评论中注意到您突出显示了当前单元格,因此添加到该突出显示的这段代码应该有助于隐藏光标:
' Code generated by record macro, and not tidied up
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThick
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThick
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThick
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThick
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
这将把边框变成黑色,当单元格被选中时它会变成白色(带有非常细的黑色轮廓)。
另一种方法是将所有单元格更改为具有灰色粗轮廓,因此在选中该框时它将具有相同的颜色轮廓。以编程方式,对代码的更改将是删除 colorindex 行,并添加
.ThemeColor = 1
取而代之,并将 TintAndShade 行更改为:
.TintAndShade = -0.5
无论使用哪种方法,您仍然会在当前单元格中看到一条细黑线。