- 帖子
- 315
- 主題
- 51
- 精華
- 0
- 積分
- 367
- 點名
- 0
- 作業系統
- win7
- 軟體版本
- office2003
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2015-9-29
- 最後登錄
- 2021-10-12
|
VBA_執行階段錯誤 "1004" 的修正。
本帖最後由 Airman 於 2015-11-21 11:09 編輯
執行到列9彈出︰
執行階段錯誤 "1004"
Class Range 的 Select方法失敗
請問︰要如何修正? 謝謝!
Private Sub CommandButton1_Click()
Dim J%, K%, tx%, ty%, tz%, b
With Sheets(2)
Sheets(1).Range("J7", "P" & Sheets(2).[R6] + 5).Copy .[J7]
tx = .[R7].End(xlDown).Row
ty = .[T5].End(xlToRight).Column
For tz = 20 To ty
.Range("T7:T" & tx).Select
For Each b In Selection
If b <> "" Then
For J = 10 To 16
For K = 10 To 16
If .Range("R" & b.Row) + 1 = .[T5] Then
If .Range("R" & b.Row) - .[T3] * 2 > 6 Then
If .Cells(.[T5] + 6, J) = .[R5] Then
If .Cells(.[T5] - 6, J) = .[R5] Then
If .Cells(.[T5] + 6, J) = .[R5] Then
With .Cells(.[T5] + 6, J): .Interior.ColorIndex = 4: .Font.ColorIndex = 3: .Font.FontStyle = "粗體": End With
With .Cells(.[T5] - .[T3] + 6, J): .Interior.ColorIndex = 45: .Font.ColorIndex = 3: .Font.FontStyle = "粗體": End With
With .Cells(.[T5] - .[T3] * 2 + 6, J): .Interior.ColorIndex = 8: .Font.ColorIndex = 3: .Font.FontStyle = "粗體": End With
End If
End If
End If
End If
End If
Next K
Next J
End If
Next b
Next tz
End With
[A1].Select
End Sub |
|