![]() |
#5
|
|||
|
|||
![]()
The macro should only work on one paragraph. (which the mouse cursor is on).
1 Select the paragraph. 2 to copy 3 Press Enter to drop a new line. 4 Paste 5 At this stage I can change the sign myself and perform the calculation manually. (Unless it is possible for the macro to also change the sign automatically). 6 Just for information - I use the macro below for the calculation: Sub MyCalculator() 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 With frmCalculator .Caption = "Total" .lblResult.Caption = iTotal .lblResult.Font.Size = 24 .Show End With End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Marcia | Excel Programming | 4 | 08-12-2022 03:54 PM |
Select entire text and then de-select certain Headings? | tq94 | Word | 3 | 02-26-2022 03:47 AM |
Select text between 2 | yacov | Word VBA | 2 | 08-15-2021 10:16 PM |
![]() |
cosmicyes | Excel Programming | 1 | 07-09-2018 02:47 AM |
![]() |
aymanharake | Excel Programming | 3 | 02-18-2017 04:09 PM |