Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Excel Substitute or Find and Replace or Macro Solution

Posted on 2011-09-06
5
Medium Priority
?
281 Views
Last Modified: 2012-05-12
I have a rather large spread sheet where I would like to have Excel find specific words in the sheet (among thousands of sentences) and replace them with my chosen words.  I use the Substitute Function but it only has up to 8 words I can substitute (find and replace) – I would like to have the ability to seek and replace 20-50 words at a time.   I am trying to figure out a way I can run this in a macro (or other solution).  
Book2.xlsx
0
Comment
Question by:mmmcdee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 24

Expert Comment

by:StephenJR
ID: 36491420
Well code could loop through a series of words, or regular expressions perhaps. Are all the words being replaced by the same word or different ones?
0
 

Author Comment

by:mmmcdee
ID: 36491443
Different Words. Replacing words within sentences.  I created a sample attached sheet.
0
 

Author Comment

by:mmmcdee
ID: 36491527
Correction:  All of the words are being replaced by the same word.
0
 
LVL 24

Accepted Solution

by:
StephenJR earned 2000 total points
ID: 36491837
Yes, thank you.
Sub x()

Dim oRgx As Object, rCell As Range, v, w

Set oRgx = CreateObject("VBScript.RegExp")

v = Range("D6:D14")
w = Join(Application.Transpose(v), "|")

With oRgx
    .Global = True
    .Pattern = w
    For Each rCell In Range("B6", Range("B6").End(xlDown))
        rCell.Offset(, 5) = .Replace(rCell, Range("D4").Value)
    Next rCell
End With

End Sub

Open in new window

0
 

Author Closing Comment

by:mmmcdee
ID: 36492345
Awesome Job
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question