Hello,
I have written a sub that calculates the number of rows in which a certain string is mentioned, and subsequently outputs another string if the number of rows is greater than or equal to 5. However, upon running it, I get an error that says:
Run-time error '1004':
Application-Defined or Object-Defined Error
However, I am unable to see how the line indicated upon debugging the code is in any way wrong. I'm hoping you can help me. The code I have written is as follows:
Sub Min_Dates()
Dim i As Long
Dim j As Long: j = 2
Dim m As Long: m = 1
Dim d As Long
Dim b As String
Dim a As String
Do
i = j
If i = 10 * m Then
m = m + 1
Cells(1, 80).Value = i
End If
Do
b = Cells(j, 1).Value
a = Cells(j + 1, 1).Value
j = j + 1
Loop Until a <> b
d = j - i
If d >= 5 Then
Cells(i, 79).Value = "Suitable"
End If
j = j + 1
Loop Until Cells(j + 1, 1).Value = "END"
End Sub
The line in yellow is what the debugging says must be correct. Can anyone spot what is wrong in the code?
I have written a sub that calculates the number of rows in which a certain string is mentioned, and subsequently outputs another string if the number of rows is greater than or equal to 5. However, upon running it, I get an error that says:
Run-time error '1004':
Application-Defined or Object-Defined Error
However, I am unable to see how the line indicated upon debugging the code is in any way wrong. I'm hoping you can help me. The code I have written is as follows:
Sub Min_Dates()
Dim i As Long
Dim j As Long: j = 2
Dim m As Long: m = 1
Dim d As Long
Dim b As String
Dim a As String
Do
i = j
If i = 10 * m Then
m = m + 1
Cells(1, 80).Value = i
End If
Do
b = Cells(j, 1).Value
a = Cells(j + 1, 1).Value
j = j + 1
Loop Until a <> b
d = j - i
If d >= 5 Then
Cells(i, 79).Value = "Suitable"
End If
j = j + 1
Loop Until Cells(j + 1, 1).Value = "END"
End Sub
The line in yellow is what the debugging says must be correct. Can anyone spot what is wrong in the code?