Hi Guys,
Thanks so much for your help. what I am trying to achieve is if I put different code to any cells (i.e. C1, E1, G1) then it will give the total beside its cell (i.e. D1, F1, H1) or any where I put the letters it will give me the total beside that cell.
Trebor 76 - I just wanted to let you know that I don't know about macro that much. I assumed that what you gave me is to create a ne wmacro. I did and named it as Calculations and paste what you gave me where it became like below. The problem is aessage pop-up saying Expected End Sub so I haven't checked your program yet
HELP!! - from stupid me
Sub Calculation()
Function LetterSum(rngData As Range) As Currency
'http://www.mrexcel.com/forum/showthread.php?t=562182
'This UDF will add the below values assigned to _
the five letters: _
"B", "R", "N", "Q", and "S".
'Note the function is case sensitive and if no matches are found zero is returned.
'Use the function as any other native Excel function, i.e.: _
=LetterSum(A5), or _
=LetterSum(A5:A9)
Dim rngCell As Range
Dim intCellLength As Integer
Dim intCharPosition As Integer
Dim curFnValue As Currency
curFnValue = 0
For Each rngCell In rngData
If InStr(rngCell, "B") + _
InStr(rngCell, "R") + _
InStr(rngCell, "N") + _
InStr(rngCell, "Q") + _
InStr(rngCell, "S") > 0 Then 'Only try add cells that contain the defines letters.
intCellLength = Len(rngCell)
For intCharPosition = 1 To intCellLength
Select Case Mid(rngCell, intCharPosition, 1)
Case Is = "B"
curFnValue = curFnValue + 2
Case Is = "R"
curFnValue = curFnValue + -0.5
Case Is = "N"
curFnValue = curFnValue + 1.2
Case Is = "Q"
curFnValue = curFnValue + 2.3
Case Is = "S"
curFnValue = curFnValue + -1
End Select
Next intCharPosition
End If
Next rngCell
LetterSum = curFnValue
End Function
End Sub