好的,...我需要清除旧的范围边界,然后再应用新的更改,我一直没有成功。应该在 “在保存单元格中设置新的持续时间
之前完成我该如何实现?
If Cells(9, Target.Column).Value = "Dur" Then 'Duration Change and Check for proper datbase coluumn
'Update Colors
'Clears Old Color
If Range("A8").Value <> Empty Then Range(Cells(Target.Row, Target.Column), Cells(Target.Row + Range("A8").Value - 1, Target.Column + 3)).Interior.Color = 16777215 'Clear Previos Colors Based on Previous Duration (if any)
'Set New Duration in holding cell
Range("A7").Value = Target.Value
'Sets New color
If Target.Value <> Empty Then Range(Cells(Target.Row, Target.Column), Cells(Target.Row + Range("A8").Value - 1, Target.Column + 3)).Interior.Color = Range("FillColor").Interior.Color 'Add New Color
'Sets Border around
If Target.Value <> Empty Then Range(Cells(Target.Row, Target.Column), Cells(Target.Row + Range("A8").Value - 1, Target.Column + 3)).BorderAround , ColorIndex:=xlAutomatic, Weight:=xlThin
End If
答案 0 :(得分:0)
这将删除范围A1
中的所有边框。
With Range("A1")
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlNone
.Borders(xlEdgeTop).LineStyle = xlNone
.Borders(xlEdgeBottom).LineStyle = xlNone
.Borders(xlEdgeRight).LineStyle = xlNone
.Borders(xlInsideVertical).LineStyle = xlNone
.Borders(xlInsideHorizontal).LineStyle = xlNone
End With
来源:宏记录器。根据GSerg的评论和文档,最好将xlNone
替换为xlLineStyleNone
(通常它们是相同的-4142
,因此两者都可以使用)。 < / p>
尽管Range.BorderAround method的文档中说:
要清除边框,必须将范围内的所有单元格的
LineStyle
属性设置为xlLineStyleNone
。
很显然,由于错误Range("A1").BorderAround LineStyle:=xlLineStyleNone
导致行不通。因此,您必须使用第一个代码块来完成它。