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
Solved

Excel Substitute or Find and Replace or Macro Solution

Posted on 2011-09-06
5
253 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
  • 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 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

861 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