I am currently facing above error when running vba as below(vba newbie here). Would you please see what is causing this error? I am using this script to parse information from a text file in excel with around 65000 rows. When I click 'debug' , it highlighted this row
If Cells(i, 2).Value = "Type: Error" And Cells(i + 5, 2).Value = " STATUS : FAILURE" Then"
Thank you.
Sub color()
Dim i As Long
Dim j As Long
j = 0
ActiveSheet.Name = "Raw data"
sheets.Add.Name = "Error"
Range("A1:B1").Value = Array("DN", "Error details")
Worksheets("Raw data").Activate
For i = 1 To Rows.Count
If Cells(i, 2).Value = "Type: Error" And Cells(i + 5, 2).Value = " STATUS : FAILURE" Then
ActiveSheet.Cells(i, 2).Select
ActiveCell.Offset(-1, 0).Copy
Worksheets("Error").Range("A2").Offset(j, 0).PasteSpecial xlPasteAll
ActiveCell.Offset(6, 0).Copy
Worksheets("Error").Range("B2").Offset(j, 0).PasteSpecial xlPasteAll
j = j + 1
ElseIf Cells(i, 2).Value = "Type: Error" And Cells(i + 4, 2).Value = "Caused by ConnectException: Connection timed out" Then
ActiveSheet.Cells(i, 2).Select
ActiveCell.Offset(-1, 0).Copy
Worksheets("Error").Range("A2").Offset(j, 0).PasteSpecial xlPasteAll
ActiveCell.Offset(3, 0).Copy
Worksheets("Error").Range("B2").Offset(j, 0).PasteSpecial xlPasteAll
j = j + 1
End If
Next i
End Sub