
Use a user-defined function to sum each cell’s
cross sum in a range
Continuing with the previous example, now we want to sum up
each cell’s cross sum in a range. Create a table like the one in Fig-
ure 13-13 and calculate cross sums in a specified range with a new
user-defined function.
4
To sum up each cell’s cross sum in a range:
1. Press <Alt+F11> open the Visual Basic Editor.
2. From the Insert menu, click Module.
3. Type the following function:
Function QsE(Area As Range)
Dim i As Integer
Dim rng As Range
For Each rng In Area
Fori=1ToLen(rng.Value)
QsE = QsE+CInt (Mid(rng.Value, i, 1))
Next i
Next rng
End Function
4. Close the VBA Editor by pressing <Alt+Q> ...