Board logo

標題: [發問] Borders屬性問題 [打印本頁]

作者: caichen3    時間: 2012-6-21 19:46     標題: 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"  是什麼原因呢??
作者: oobird    時間: 2012-6-21 22:30

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.對兩個區域分別設外框粗線
作者: GBKEE    時間: 2012-6-22 07:17

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

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




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)