自我回答......我明白了。
For CellA = 1 To 20
For CellB = 1 To 40
Set Curcell = ActiveSheet.Cells(CellB, CellA)
Curcell.Select
For i = 1 To 4
If i = 1 Then X = "xlEdgeBottom"
If i = 2 Then X = "xlEdgeLeft"
If i = 3 Then X = "xlEdgeRight"
If i = 4 Then X = "xlEdgeTop"
**If Selection.borders(X) = xlThick Then** Selection.borders(X) = xlMedium
Next i
Next CellB
Next CellA
我的目标:如果边框很厚,请将其设为中等。所有细胞都在这个范围内,但它们是多张。
为什么这不起作用?我在“If Selection.borders(X)= xlThick Then”中有“类型不匹配”
我知道它很粗但不应该有效吗?我能做什么?我用Google搜索了,但也许我输错了字。
答案 0 :(得分:0)
Sub borders()
For CEllA = 1 To 20
For CellB = 1 To 40
Set Curcell = ActiveSheet.Cells(CellB, CEllA)
Curcell.Select
If Selection.borders(xlEdgeBottom).Weight = xlThick Then Selection.borders(xlEdgeBottom).Weight = xlMedium
If Selection.borders(xlEdgeLeft).Weight = xlThick Then Selection.borders(xlEdgeLeft).Weight = xlMedium
If Selection.borders(xlEdgeRight).Weight = xlThick Then Selection.borders(xlEdgeRight).Weight = xlMedium
If Selection.borders(xlEdgeTop).Weight = xlThick Then Selection.borders(xlEdgeTop).Weight = xlMedium
Next CellB
Next CEllA
End Sub