View Single Post
 
Old 07-17-2021, 10:29 PM
yacov yacov is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Oct 2019
Posts: 146
yacov is on a distinguished road
Default

Thanks for the update. I added to the macro an automatic selection of the paragraph. I would like to check if it is possible for the macro to do a calculation on the whole document. For this I need the result of the calculation to be recorded in the document in each paragraph. Is it possible?

Sub MyCalculatorSelect()
Selection.Paragraphs(1).Range.Select
Dim aChar As Variant, aRng As Range, iTotal As Long
Set aRng = Selection.Range
For Each aChar In aRng.Characters
Select Case AscW(aChar)
Case 1488 To 1497: iTotal = iTotal + AscW(aChar) - 1487
Case 1498: iTotal = iTotal + 20
Case 1499: iTotal = iTotal + 20
Case 1500: iTotal = iTotal + 30
Case 1501: iTotal = iTotal + 40
Case 1502: iTotal = iTotal + 40
Case 1503: iTotal = iTotal + 50
Case 1504: iTotal = iTotal + 50
Case 1505: iTotal = iTotal + 60
Case 1506: iTotal = iTotal + 70
Case 1507: iTotal = iTotal + 80
Case 1508: iTotal = iTotal + 80
Case 1509: iTotal = iTotal + 90
Case 1510: iTotal = iTotal + 90
Case 1511: iTotal = iTotal + 100
Case 1512: iTotal = iTotal + 200
Case 1513: iTotal = iTotal + 300
Case 1514: iTotal = iTotal + 400
Case 45: iTotal = iTotal * -1 'a minus sign
End Select
Next aChar
MsgBox iTotal
End Sub
Reply With Quote