Search and Replace VBA Challenges

yonyon7

New Member
Joined
Dec 28, 2013
Messages
2
Hi,


I have 2 search and replace vba challenges I'm struggling with:



  1. Replace based on partial string – replacing whole word based on partial string. Using "str* " is not always useful since line breaks are ignored that way, and wildcards aren’t useful when implementing with strcomp (selection.replace is a more limited option..) – for example, replace words containing @ (or "http" or anything else..) with nothing (word can be first, last, followed by ","/line break/…, etc.)
  2. Repetitive characters - replacing repetitive characters (such as "ffff") with only two instances of the text. So "ffffff" and "fff" and "ff" are all replaced with "ff". the thing is – it should be generic to apply to all characters ("fffff", "rrrrrrr", "aaa"…)

Thanks!!
Yon
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Have you looked at Regular Expressions ("RegEx") and VBA? It's a powerful tool for the kind of manipulation you're talking about. I don't know enough myself to respond to your specific questions. I've only used RegEx once to solve one specific problem. It did take a while to get the syntax correct.

HTH,
Nolan
 
Upvote 0

Forum statistics

Threads
1,203,506
Messages
6,055,796
Members
444,825
Latest member
aggerdanny

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top