Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 01-29-2024, 11:00 PM
yacov yacov is offline select until = Windows 10 select until = Office 2016
Competent Performer
select until =
 
Join Date: Oct 2019
Posts: 146
yacov is on a distinguished road
Default

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
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
select until = Select until last row 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
select until = Select a row in a different tab cosmicyes Excel Programming 1 07-09-2018 02:47 AM
select until = How to select row aymanharake Excel Programming 3 02-18-2017 04:09 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:11 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft