Я недавно столкнулся с ошибкой компиляции VBA: «Ожидается: If или Select, Sub или Function или Свойство или Тип, С или Enum или Конец оператора»
Все мои операторы if закрыты, и я не вижу других ошибок с синтаксисом.
Вот код:
Option Explicit
Sub whileloop()
Dim intCurrentRow As Integer
Dim intLastRow As Integer
Dim strPrefix As String
Dim strSuffix As String
Dim strOperation As String
Dim snglLaborMinutes As Single
intCurrentRow = 3
intLastRow = Cells(Rows.Count, 0).End(xlUp).Row
strPrefix = Cells(2, 0).Value
strSuffix = Cells(2, 1).Value
strOperation = Cells(2, 4).Value
snglLaborMinutes = Cells(2, 3).Value
While intCurrentRow <= intLastRow
If strPrefix = Cells(intCurrentRow, 0).Value Then
If strSuffix = Cells(intCurrentRow, 1).Value Then
If strOperation = Cells(intCurrentRow, 4).Value Then
snglLaborMinutes = snglLaborMinutes + Cells(intCurrentRow, 3).Value
Cells(intCurrentRow - 1, 3).Value = snglLaborMinutes
Rows(1).EntireRow.Delete
intLastRow = intLastRow - 1
intCurrentRow = intCurrentRow - 1
Else
strOperation = Cells(intCurrentRow, 4).Value
End If
Else
strSuffix = Cells(intCurrentRow, 1).Value
End If
Else
strPrefix = Cells(intCurrentRow, 0).Value
End If
intCurrentRow = intCurrentRow + 1
End While
End Sub