[VBA ] 請問型態不符合的問題
我針對一些數據判定大小來上色
第三行和第五到七行都是有著小數點後兩位的數字
執行結果其中一行程式碼出現型態不符合的錯誤
請各位幫我看一下是哪裡有問題,謝謝!
程式碼如下 :
Dim i As Integer
Dim n As Integer
Dim p As Single
Dim p1 As Single
n = WorksheetFunction.CountA(Columns("A:A"))
Rows("7:300").Select
Selection.Interior.ColorIndex = xlNone
For i = 8 To n + 5
p = Cells(i, 3).Value
For j = 5 To 7
p1 = Cells(i, j).Value <--- 這一行呈現黃色,錯誤訊息為
執行階段錯誤 '13':型態不符合
If WorksheetFunction.And(p < (p1 * 1.05), p > p1) Then
Cells(i, j).Select
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
End With
ElseIf p < p1 Then
Cells(i, j).Select
With Selection.Interior
.ColorIndex = 50
.Pattern = xlSolid
End With
End If
Next j
Next i
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 1.169.180.124
→
01/02 02:54, , 1F
01/02 02:54, 1F
推
01/02 09:21, , 2F
01/02 09:21, 2F
→
01/02 09:22, , 3F
01/02 09:22, 3F
→
01/02 10:35, , 4F
01/02 10:35, 4F
→
01/02 10:36, , 5F
01/02 10:36, 5F
→
01/02 11:36, , 6F
01/02 11:36, 6F
→
01/02 11:36, , 7F
01/02 11:36, 7F
推
01/03 22:05, , 8F
01/03 22:05, 8F
→
01/03 22:10, , 9F
01/03 22:10, 9F
→
01/04 09:02, , 10F
01/04 09:02, 10F
→
01/04 09:03, , 11F
01/04 09:03, 11F
討論串 (同標題文章)
Visual_Basic 近期熱門文章
PTT數位生活區 即時熱門文章