'VBA Do-while function does not check the condition (with error pictures)
I want to delete the same value in column C and take the average of the corresponding values in column D. But it seems the Do-Until function does not check the condition?
the first check about the line number of the first duplicated No., which works fine
the second check shows the pointer mover to line 6 where the value in the C column is empty, and the Do-while function should not run, but the message box still popped up and followed an error warning

i = 2
'Do while Sheets(1).Range("C" & i).Value is not empty
Do While IsEmpty(Sheets(1).Cells(i, "C").Value) = False
If Sheets(1).Cells(i, "C").Value = Sheets(1).Cells(i + 1, "C").Value Then
StartNo = i
MsgBox StartNo
Do While Sheets(1).Cells(i + 1, "C").Value = Sheets(1).Cells(i, "C").Value
i = i + 1
Loop
EndNo = i
Sheets(1).Range("D" & StartNo) = WorksheetFunction.Average(Range("D" & StartNo & ":D" & EndNo))
Sheets(1).Rows(StartNo + 1 & ":" & EndNo).Delete
i = StartNo
End If
i = i + 1
Loop
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

