Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 05-25-2022, 02:30 AM
Mattc1978 Mattc1978 is offline run vba script in word for removing certain characters Windows 10 run vba script in word for removing certain characters Office 2019
Novice
run vba script in word for removing certain characters
 
Join Date: May 2021
Posts: 13
Mattc1978 is on a distinguished road
Default Almost there



Quote:
Originally Posted by macropod View Post
Does for me...
Hi,

So I got them to both work, which is fantastic again!

One last thing, can it be extended so that if it is just an empty cell that it is also removed, and can the macros be combined? Into ONE?#

Thanks Again.

Matt
Reply With Quote
  #17  
Old 05-25-2022, 04:21 PM
macropod's Avatar
macropod macropod is offline run vba script in word for removing certain characters Windows 10 run vba script in word for removing certain characters Office 2016
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

It does, if 'Info:' the only thing in the cell. You asked for a macro that works as follows
Quote:
Originally Posted by Mattc1978 View Post
What I'd really want is if the cell only contains "info:" then delete the/ remove the cell
I suspect you still have cells containing rather more than that (e.g. 'header' content before 'Info:', spaces, paragraph breaks, etc. after 'Info:'). Try the following macro, which combines both the text cleanup and row deletion - accommodating that 'extra' content:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Format = False
    .Forward = True
    .Wrap = wdFindContinue
    .Text = "[\[\]\*“”""""]"
    .MatchWildcards = True
    .Replacement.Text = ""
    .Execute Replace:=wdReplaceAll
    .Text = "Info[: ^s.^t^13]{1,}"
    .Replacement.Text = ""
    .Wrap = wdFindStop
  End With
  Do While .Find.Execute
    If .Information(wdWithInTable) = True Then
      If .End = .Cells(1).Range.End - 1 Then .Rows.Delete
    End If
    .Collapse wdCollapseEnd
  Loop
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #18  
Old 06-08-2022, 05:37 AM
Mattc1978 Mattc1978 is offline run vba script in word for removing certain characters Windows 10 run vba script in word for removing certain characters Office 2019
Novice
run vba script in word for removing certain characters
 
Join Date: May 2021
Posts: 13
Mattc1978 is on a distinguished road
Default

Thanks Paul,

I will look at this and fingers crossed all sorted.

I will feedback shortly.

Many Thanks Matt
Reply With Quote
Reply

Tags
ctrlh, dunce, vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
run vba script in word for removing certain characters Visual basic Word Script To Remove Specific Areas of a Word Doc mackied Word VBA 9 07-30-2017 03:10 PM
run vba script in word for removing certain characters Removing characters from a cell tonydoneese Excel 4 01-12-2016 07:41 AM
Strange Characters appear when selecting SHOW ALL NON PRINTING CHARACTERS ann Amber Word 1 08-01-2015 08:06 PM
Junk characters (box-like characters) in Word file Sashikala Word 1 04-20-2010 02:03 PM
Removing data between two characters Voodoo Child Excel 1 11-26-2009 01:39 PM

Other Forums: Access Forums

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