Custom VBA Functions
Here we show how VBA can be used to run custom functions – instead of using Excel formulae.
Screenshots


VBA Module Code – Separate Text
VBA
Function separate_text(a As String) As String
Application.Volatile
Dim i As Integer
Dim s As String
For i = 1 To Len(a)
s = Mid(a, i, 1)
If IsNumeric(s) = False Then
separate_text = separate_text & s
End If
Next i
End Function
VBA Module Code – Bonus
VBA
Function bonus(item, price)
If item >= 20 Then
bonus = item * price * 0.3
End If
If item < 20 And item > 10 Then
bonus = item * price * 0.2
End If
If item >= 1 And item < 11 Then
bonus = item * price * 0.1
End If
End Function
Download
The full file can be downloaded here:
Feedback
Submit and view feedback