Pizza Tips - Simple Addition In Word Document
Friends, my son is delivering Pizza. He can make $80 some evenings.
We want to keep track of money he brings in each night by typing in two or three numerals amounting to his newTips. like 50 or 80 or 100
We would open the old document & type the 50 or 80 or 100 at the top-left in the document. - Then run the Macro.
NewTips will be the first word in the document.
Then we want to add this to the oldTotal, the second word in the document.
After the macro runs, we want the new total to replace the old total.
Before we run the Macro, After we type in the newTips of $50 this is what the document will look like:
50
30 Total
10 Monday, September 4, 2017
10 Saturday, September 2, 2017
10 Friday, September 1, 2017
Here's my attempt to use Range in a Macro,
Sub Macro11()
'
' Macro11 Macro
'
'
Dim newTips As Range
Set newTips = ActiveDocument.Range(Start:=ActiveDocument.Words(1 ).Start, End:=ActiveDocument.Words(1).End)
Dim oldTotal As Range
Set oldTotal = ActiveDocument.Range(Start:=ActiveDocument.Words(2 ).Start, End:=ActiveDocument.Words(2).End)
Dim newTotal As DataObject
Dim strClip As String
Set newTotal = New DataObject
newTotal = newTips + oldTotal
newTotal.SetText strClip
newTotal.PutInClipboard
Selection.HomeKey Unit:=wdStory
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.PasteAndFormat (wdFormatOriginalFormatting)
End Sub
|