我试图通过将边缘涂成白色来使单元看起来无边界。这是我的代码,该死的东西不起作用。感谢您纠正它。
Dim cel As Range
For Each cel In Range(Cells(4, 1), Cells(Worksheets("Deliverable-Epic-Story Progress").UsedRange.Rows.Count, 15))
With cel.Borders
If .Item(xlEdgeTop).LineStyle <> xlLineStyleNone Then
.Item(xlEdgeTop).Color = vbWhite
End If
If .Item(xlEdgeBottom).LineStyle <> xlLineStyleNone Then
.Item(xlEdgeBottom).Color = vbWhite
End If
End With
Next
**更新** 如果有帮助,请附上图片。
我在@Big Ben共享的链接中使用了此代码。
Private Sub TurnOffGridLines(target As Worksheet)
Dim view As WorksheetView
For Each view In target.Parent.Windows(1).SheetViews
If view.Sheet.Name = target.Name Then
view.DisplayGridlines = False
Exit Sub
End If
Next
End Sub
我这样称呼那个潜艇,它出错了。我的工作表名称是“ Deliverable-Epic-Story Progress”
TurnOffGridLines ("Deliverable-Epic-Story Progress")
答案 0 :(得分:1)
首先,似乎您正在重新发明功能。我只是隐藏网格。
基于this question,我将添加以下内容:
Private Sub TurnOffGridLines(target As Worksheet)
Dim view As WorksheetView
For Each view In target.Parent.Windows(1).SheetViews
If view.Sheet.Name = target.Name Then
view.DisplayGridlines = False
Exit Sub
End If
Next
End Sub
并向其传递一个 Worksheet 变量,而不是String
。
Dim ws as Worksheet
Set ws = ThisWorkbook.Worksheets("Deliverable-Epic-Story Progress")
TurnOffGridLines target:=ws
您只想手动执行此操作,查看> 网格线或 Alt + W + < kbd> V + G 。
答案 1 :(得分:0)
您不必将它们变白,请将.LineStyle
的{{1}}属性设置为无。
Borders
如果您确实想要底部白色:
.Borders(xlEdgeBottom).LineStyle = xlLineStyleNone
或
.Borders(xlEdgeBottom).ColorIndex = 2