返回列表 上一主題 發帖

[發問] Borders屬性問題

[發問] Borders屬性問題

請問各位大大
以下是"刪除"按鈕的程度碼
Private Sub CommandButton2_Click()
Dim a As Integer
Dim b As Integer
Dim xR As Integer
Dim xT As Integer
Dim gyou As Integer
xR = ActiveCell.Row
xT = ActiveCell.Column
a = Range("A1").Value
b = Range("A2").Value
If xR = 1 And xT > 2 And xT <= a + 2 Then
   gyou = ActiveCell.Column
   ActiveSheet.Columns(gyou).Delete
   Range("A1").Value = Range("A1").Value - 1
   a = Range("A1").Value
ElseIf xR > 1 And xR <= b + 1 Then
   Cells(xR, "B").Resize(, a + 2).Delete xlUp
   Range("A2").Value = Range("A2").Value - 1
   b = Range("A2").Value
End If

Range(Cells(1, 2), Cells(b + 4, a + 2)).Borders(xlEdgeRight).Weight = xlThick
Range(Cells(1, 2), Cells(b + 4, a + 2)).Borders(xlEdgeLeft).Weight = xlThick
Range(Cells(1, 2), Cells(b + 4, a + 2)).Borders(xlEdgeBottom).Weight = xlThick
Range(Cells(1, 2), Cells(1, a + 2)).Borders(xlEdgeBottom).Weight = xlThick

End Sub

執行後出現"無法設定種類Borders的屬性Weight"  是什麼原因呢??

創新專安Pugh概念選擇.rar (25.65 KB)

寶寶

Range(Cells(1, 2), Cells(b + 4, a + 2)).Borders.LineStyle = xlNone
Range(Cells(1, 2), Cells(b + 4, a + 2)).Borders.LineStyle = xlContinuous
Range(Cells(1, 2), Cells(b + 4, a + 2)).BorderAround , 4, 1
Range(Cells(1, 2), Cells(1, a + 2)).BorderAround , 4, 1
1.先取消所有框線
2.設置範圍的所有細線
3.對兩個區域分別設外框粗線

TOP

回復 2# oobird
你的方法是可解除錯誤
但問題是為何兩個工作表的B1:B11 儲存格, 使用指令[儲存格格式] 都失效

TOP

這問題很難理解,只有部份欄位不能設置格式
也許用新版製作的資料做相容性轉換時破壞的。
所以我嘗試用代碼取消框線,這樣就能修正既有的錯誤了。

TOP

        靜思自在 : 做好事不能少我一人,做壞事不能多我一人。
返回列表 上一主題