Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-28-2011, 08:46 PM
bthart bthart is offline Word Find and Replace Query Windows 7 32bit Word Find and Replace Query Office 2007
Novice
Word Find and Replace Query
 
Join Date: Dec 2011
Posts: 1
bthart is on a distinguished road
Default Word Find and Replace Query

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
Reply With Quote
  #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: 21,962
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
Reply



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 12:07 AM.


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