![]() |
#1
|
|||
|
|||
![]()
Hi,
I have a pricelist with a heap of prices on it. Each price is formatted with a decimal. e.g 38.21,3.58,985.15. I have used the following line to find each price. find - <[0-9]@.[0-9]@> Is there a wildcard which I can use in the replace field to multiply each price by a certain value - e.g double each price. Or is there another way I can do it. Thanks, Brian |
#2
|
||||
|
||||
![]()
Hi Brian,
Out of the box, there's nothing in Word's Find/Replace tool that'd do what you're asking. A macro would be required. For example: Code:
Sub UpdatePrices() Application.ScreenUpdating = False Dim RngFnd As Range, SngVal As Single, i As Integer Set RngFnd = Selection.Range With Selection.Range If Len(.Text) < 4 Then Exit Sub On Error Resume Next SngVal = CSng(InputBox("By what should each value be multiplied?", "Price Changer")) If SngVal = 0 Then Exit Sub With .Find .ClearFormatting .Text = "[0-9,]{1,}.[0-9]{2}>" .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Format = False .MatchWildcards = True .Execute End With Do While .Find.Found If .End > RngFnd.End Then GoTo Done i = i + 1 .Text = Format(CSng(.Text) * SngVal, "#,##0.00") .Collapse wdCollapseEnd .Find.Execute Loop End With Done: Set RngFnd = Nothing Application.ScreenUpdating = True MsgBox i & " price(s) updated." End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] Last edited by macropod; 12-29-2011 at 12:57 AM. Reason: Bug fix! |
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
paulkaye | Word | 4 | 12-06-2011 11:05 PM |
find&replace word in uppercase with word in lowercase | andrei | Word | 3 | 10-03-2011 05:11 AM |
![]() |
slayda | Word | 3 | 09-14-2011 02:16 PM |
![]() |
kjxavier | Word | 9 | 08-11-2011 04:47 AM |
![]() |
shabbaranks | Excel | 4 | 03-19-2011 08:38 AM |