Мой лист Excel содержит эти данные, 7 столбцов
sl.no | bed | 2| 4| 3|4|3|
иногда столбец № 7 пуст, и только тогда я получаю сообщение об ошибке
И мой код
Sub sup_cal_area_sft()
Dim lru, plru As Long
Dim myless As String
Dim ttr_l, ttr_p, ttr_nql, ttr_nqp, trft As Variant
On Error GoTo Errorcatch
myless = "*" & "LESS" & "*"
With ActiveSheet
lru = .Cells(.Rows.Count, "c").End(xlUp).Row
plru = .Cells(.Rows.Count, "h").End(xlUp).Row + 2
End With
For i = plru To lru
ttr_l = "=PRODUCT((C" & i & "+D" & i & "/12)*(E" & i & "+F" & i & "/12)*-G" & i & ")"
ttr_p = "=PRODUCT((C" & i & "+D" & i & "/12)*(E" & i & "+F" & i & "/12)*G" & i & ")"
ttr_nql = "=PRODUCT((C" & i & "+D" & i & "/12)*-(E" & i & "+F" & i & "/12)"
ttr_nqp = "=PRODUCT((C" & i & "+D" & i & "/12)*(E" & i & "+F" & i & "/12)"
trft = "=PRODUCT((C" & i & "+D" & i & "/12)*G" & i & ")"
If Cells(i, 5) <> "" Then
If UCase(Cells(i, 2).Value) Like myless Then 'negative value
If Cells(i, 7) <> "" Then
Cells(i, 8) = ttr_l
Else
Cells(i, 8) = ttr_nql
End If
ElseIf Not UCase(Cells(i, 2).Value) Like myless Then 'positive Value
If Cells(i, 7) <> "" Then
Cells(i, 8) = ttr_p
Else
Cells(i, 8) = ttr_nqp
End If
End If
' RFT Calculaion
ElseIf Cells(i, 3) <> "" And Cells(i, 5) = "" and cells(i,4) <> "" Then
Cells(i, 8) = trft
' Blank
Else
Cells(i, 8) = ""
End If
Next i
Cells(lru + 3, 2).Select
exit sub
Errorcatch:
MsgBox Err.Description
End Sub