我寫了這段代碼。我不明白爲什麼我得到錯誤:End If without block如果End If without block如果錯誤
Sub mytest()
Dim i As Integer
Dim s As Integer
Dim j As Integer
Dim p As Integer
Dim k As Integer
s = 0
With Worksheets("mysheet")
.Range("B28:B75").Select
For i = 28 To 75
If Cells(i, 2).Value > 0 Then Cells(i, 2).Interior.Color = RGB(255, 255, 255)
s = s + 1
End If
Next i
.Range("A28:A75").Select
For j = 28 To 75
If Cells(i, 2).Value = 0 Then Cells(i, 2).Interior.Pattern = xlPatternLightDown
Cells(i, 2).Interior.Color = RGB(255, 255, 255)
End If
Next j
p = 75 - s
For k = 1 To s
Cells(s + k, 1).Interior.Color = RGB(18, 0, 0)
Next k
End With
End If子句wasnt省略。我不明白爲什麼我得到錯誤
嘗試在'Then'後面移動語句 –
請注意,您的錯誤不是'Block If without End If',而是'End If without Block If'。您沒有缺少'End If',您有太多;)(請參閱下面的宏人或[此答案](http://stackoverflow.com/a/22580564/5350831)的答案)。 –