업무 활용 엑셀

에듀파인 예산입력자료에서 산출식 문자열 계산 모듈(CalStr)

MorningPhys 2019. 12. 16. 16:18

에듀파인 예산입력자료 엑셀에서 활용된 모듈입니다. 

해당 모듈은 셀에서 텍스트와 같이 입력된 값에서 숫자만 가지고와 산술계산을 하는 모듈입니다. 

CalStr 모듈

 

Function CalStr(strS As String)

Dim i As Integer
Dim Tmp_Text, strText As String


On Error Resume Next
Tmp_Text = ""
For i = 1 To Len(strS) + 1
    strText = Mid(strS, i, 1)

    If (strText Like "[0-9]" Or strText Like "[+*/.%)(-]") Then
        Tmp_Text = Tmp_Text & strText
    End If

Next i
    
If Tmp_Text = "" Then
    CalStr = 0
Else
    CalStr = Evaluate(Tmp_Text)
    
    If CalStr Mod 1000 > 0 Then
        CalStr = ((CalStr \ 1000) + 1) * 1000
    End If
End If

End Function

Function CalMinus(thisY As Double, lastY As Double)

    CalMinus = thisY - lastY

End Function

반응형