我有一个命名表作为范围(列表对象),我需要更改一个单元格的边缘顶部边框颜色,但代码不起作用,我需要一些帮助。以下是代码的一部分:
With ws
.Unprotect Password:="pAtRiCiA"
For Each ctrl In Me.Controls
If Left(ctrl.Name, 5) = "texto" Then
If ultimafila - 1 <> 8 Then
If ctrl.Name = "textoCausas" Then
If Not IsError(Application.Match(Me.textoCausas.Value, ws.ListObjects(ActiveSheet.Name).ListColumns(1).DataBodyRange, 0)) Then
.Cells(ultimafila, ctrl.TabIndex) = ""
.ListObjects(ActiveSheet.Name).ListColumns(1).DataBodyRange(ultimafila, 1).Borders(xlEdgeTop).LineStyle = xlContinuous
.ListObjects(ActiveSheet.Name).ListColumns(1).DataBodyRange(ultimafila, 1).Borders(xlEdgeTop).ColorIndex = 3
.ListObjects(ActiveSheet.Name).ListColumns(1).DataBodyRange(ultimafila, 1).Borders(xlEdgeTop).Weight = xlThick
Else
.Cells(ultimafila, ctrl.TabIndex) = ctrl.Value
End If
Else
.Cells(ultimafila, ctrl.TabIndex) = ctrl.Value
End If
Else
.Cells(ultimafila, ctrl.TabIndex) = ctrl.Value
End If
End If
Next ctrl
.Cells(ultimafila, 2) = txtControles.Value
.Rows(ultimafila).AutoFit
.Rows(ultimafila).RowHeight = .Cells(ultimafila, 1).Height + 12
.Protect Password:="pAtRiCiA", DrawingObjects:=True, Contents:=True, Scenarios:=True
End With