Public Sub CalcThis2()
Dim inputDiap As Range, insp As Range, lube As Range, tigh As Range, repl As Range
Dim fStr$, fStrOut$, lRow&
With ActiveSheet
lRow = .[A1].SpecialCells(xlLastCell).Row
For i = 4 To lRow
fStrOut = ""
For Each iCell In .Cells(i, stcol).Resize(1, (ltcol - stcol + 1))
' fStr = IIf(InStr(iCell.Text, "I") > 0, Replace(UCase(iCell.Text), "I", "*" & .Cells(i, "U").Text & "+"), UCase(iCell.Text))
fStr = IIf(InStr(fStr, "L") > 0, Replace(fStr, "L", "+"), fStr) 'Replace(fStr, "L", "*" & .Cells(1, "BW").Text & "+"), fStr)
' fStr = IIf(InStr(fStr, "T") > 0, Replace(fStr, "T", "*" & .Cells(i, "W").Text & "+"), fStr)
'
' fStr = IIf(InStr(fStr, "R") > 0, Replace(fStr, "R", "*" & .Cells(i, "X").Text & "+"), fStr)
'
fStrOut = fStrOut & fStr
Next
If fStrOut <> "" Then
leng = Len(fStrOut)
fStrOut = Mid(fStrOut, 1, leng - 1)
End If
' Do While Right(fStrOut, 1) = " "
' fStrOut = Left(fStrOut, Len(fStrOut))
' Loop
' Do While Left(fStrOut, 1) = "+" Or Left(fStrOut, 1) = "*"
' fStrOut = Mid(fStrOut, 2)
' Loop
'
If IsError(Evaluate(Replace(fStrOut, ",", "."))) Then 'Evaluate(fStrOut)
.Cells(i, ltcol + 1) = 0
Else
.Cells(i, ltcol + 1) = Evaluate(Replace(fStrOut, ",", "."))
End If
Next i
End With
End Sub
But it stil does not give the answer that I want, which is 20
Bookmarks