#1
|
|||
|
|||
Macro - replace with condition
Hi
I have the following code which replaces the .00 with blanks (nothing). In otherwords it removes .00 from the document. But currently it is removing ".00" if it find anywhere such as .008 will change to 8. I only want to change if ".00" is like 5.00. so only in this case it should remove ".00". Sub find() With Selection.find .Text = ".00" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With 'Selection.find.Execute replacewith:="" not required as the code is there. Selection.find.Execute Replace:=wdReplaceAll End Sub |
#2
|
||||
|
||||
hi ubns,
Three things: 1. When posting Word-related questions, please post in the appropriate Word forum (the Word VBA forum in this case). 2. When posting code, please use the code tags on the 'Go Advanced' tab, with properly-formatted code. 3. Don't use Reserved words like 'find' for a macro's name. Try: Code:
Sub DeleteCents() Application.ScreenUpdating = True With Selection.Find .ClearFormatting .Replacement.ClearFormatting .Text = ".00>" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = True .MatchSoundsLike = False .MatchAllWordForms = False .Execute Replace:=wdReplaceAll End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
macro or find/replace | JamesVenhaus | Word | 2 | 02-27-2012 03:34 PM |
Macro to replace From Address in Outlook | RlcZek113524 | Outlook | 0 | 06-08-2011 02:20 PM |
Macro to Replace Fonts | ballj_35 | Word | 3 | 05-10-2011 01:10 AM |
check with condition | karti | Word | 2 | 03-15-2011 06:06 AM |
Find and Replace Macro - A Better Way | Tribos | Word VBA | 0 | 10-08-2008 03:22 AM |