엑셀 textsum 메크로
적산 할때 유용하죠!
alt+ f11 하신후에 모듈추가하여 카피해서 붙여넣으시면 됩니다.
Function textsum(strChr As String) As Double
Dim i As Integer
Dim j As Integer
Dim ii As Integer
Dim newStr As String
Dim strTemp As String
i = Len(strChr)
ii = 0
If i = 0 Then Exit Function
For j = 1 To i
strTemp = Mid(strChr, j, 1)
'[]안에 들어가는 글자나 숫자를 무시
If strTemp = "[" Then
ii = 1
ElseIf strTemp = "]" Then
ii = 0
End If
If ii = 0 Then
'나머지 숫자 및 연산기호를 재배치하여 계를 냄
Select Case strTemp
Case "{"
newStr = newStr & "ABS("
Case "}"
newStr = newStr & ")"
Case "×"
newStr = newStr & "*"
Case "÷"
newStr = newStr & "/"
Case "~"
newStr = newStr & "-"
Case "+", "-", "*", "/", "(", ")", "^", "."
newStr = newStr & strTemp
Case Else
If IsNumeric(strTemp) Then
newStr = newStr & strTemp
End If
End Select
End If
Next j
textsum = Application.Evaluate(newStr)
End Function