Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-31-2023, 02:41 AM
RobiNew RobiNew is offline Replace with zero any digit string of any length containing the letter O Windows 10 Replace with zero any digit string of any length containing the letter O Office 2016
Competent Performer
Replace with zero any digit string of any length containing the letter O
 
Join Date: Sep 2023
Posts: 208
RobiNew is on a distinguished road
Default Replace with zero any digit string of any length containing the letter O


I am trying to work out a macro that replaces the letter O with zero ('0') in any position within a digit string. I cannot go any further into the tentative code here below. Thanks!
Code:
Sub LetterToZero()
'Replace with zero any digit string of any length containing the letter O
'Test sequence: This sequence 145O or this 4O56 or this O4578
    Set aRng = ActiveDocument.StoryRanges(wdMainTextStory)
    With aRng.Find
      .ClearFormatting
      .Text = "O[0-9]"
'      .Text = "[0-9]O"
'       find letter O inside digit string
'      .Replacement.Text = "0" 'Replace only the letter O
      .Wrap = wdFindStop
      .Format = False
      .MatchCase = False
      .MatchWildcards = True
      .Execute
'If .Found = True Then MsgBox "Found " & aRng.Text
    End With
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace apostrophe mark before a digit RobiNew Word VBA 13 10-22-2023 05:37 PM
Replace with zero any digit string of any length containing the letter O Sort by String Length nmkhan3010 Word VBA 1 11-01-2021 01:50 PM
Replace with zero any digit string of any length containing the letter O Remove everything after the last instance of a digit/letter combo 14spar15 Excel 5 05-14-2019 05:29 AM
Replace with zero any digit string of any length containing the letter O Wildcard replace any string in context with a specified string wardw Word 7 05-07-2018 09:13 AM
Replace with zero any digit string of any length containing the letter O A challenging digit by digit manipulation, rotate the digit in range of 0 to 9 laucn Excel Programming 14 05-17-2015 12:12 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:31 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