Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 12-29-2011, 12:45 AM
macropod's Avatar
macropod macropod is offline Word Find and Replace Query Windows 7 64bit Word Find and Replace Query Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word Find and Replace Query Bad view when using Find and Find & Replace - Word places found string on top line 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
Word Find and Replace Query Is there a way to use "find/replace" to find italics words? slayda Word 3 09-14-2011 02:16 PM
Word Find and Replace Query Find and Replace kjxavier Word 9 08-11-2011 04:47 AM
Word Find and Replace Query Help with find and replace or query and replace shabbaranks Excel 4 03-19-2011 08:38 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:07 PM.


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