Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-10-2024, 05:26 PM
Guessed's Avatar
Guessed Guessed is offline Find and replace the number format after vbTab Windows 10 Find and replace the number format after vbTab Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default


Here is a shorter option which works for me and applies the red colour as you requested.
Code:
Sub Repl_Digits_W__Wds_3()
  'In selected paragraphs, replace the digits that start tabbed paras with wds.
  Dim para As Paragraph, dgt As Range, arrText() As String
  
  arrText = Split("zero one two three four five six seven eight nine", " ")
  For Each para In Selection.Range.Paragraphs
    If para.Range.Text Like vbTab & "[0-9] *" Then    'Search for only single digits:
      Set dgt = para.Range.Characters(2)
      dgt.Text = arrText(dgt.Text)
      dgt.Font.ColorIndex = wdRed
    End If
  Next para
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #2  
Old 01-11-2024, 01:50 AM
vivka vivka is offline Find and replace the number format after vbTab Windows 7 64bit Find and replace the number format after vbTab Office 2016
Expert
 
Join Date: Jul 2023
Posts: 302
vivka is on a distinguished road
Default

Guessed, your code is the best solution, I think! And your "[0-9] *" is brilliant! I live and learn.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't find and replace (Appendix + any number) Muse1 Word 1 12-30-2023 08:36 AM
Find and replace the number format after vbTab find and replace with format karkey Word VBA 2 08-02-2022 03:04 PM
Find/Replace using format of cell catflap Excel 1 09-11-2017 07:28 AM
Find and replace the number format after vbTab Need Help to Find a Number and replace Allen Word 5 11-20-2014 10:33 PM
Find and replace the number format after vbTab Find and Replace maintain format winningson Word 3 01-19-2013 05:38 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:28 AM.


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