• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 367
  • Last Modified:

find and replace values

folks

based on a value in sheet 1 field b1 I would like to loop thru sheet 2 the entire column "a" and find and replace values containing "car" with  the word "transport"
if sheet 1 b1 = 1 then replace values that are months with seaons

i.e

if sheet 1 b1 = "1"

the replace "car" with  "transport"

if

if sheet 1 b1 = "2"

the replace "snacks" with  "food"

if sheet 1 b1 = "3"

the replace "pills" with  "medicine"
0
rutgermons
Asked:
rutgermons
1 Solution
 
rutgermonsAuthor Commented:
I guess substitute may be the better term used for this
0
 
QlemoC++ DeveloperCommented:
In Excel VBA:
Sub SubstA()
  strFind = ""
  strRepl = ""
  Select Case [Sheet1!B1].Value
    Case 1: strFind = "car": strRepl = "transport"
    Case 2: strFind = "snacks": strRepl = "food"
    Case 3: strFind = "pills": strRepl = "medicine"
  End Select
  [Sheet2!A:A].Replace strFind, strRepl, xlWhole
End Sub

Open in new window

Calling that sub (macro) should perform that simple task.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now