Solved

VBA replace kind of macro

Posted on 2016-11-02
11
61 Views
Last Modified: 2016-11-27
Hi Experts

Can there be way or macro be written where search is made to the whole sheet and whereever the following left contents are found they are get replaced by the right hand side contents.

Code                        Description
DK, R                       Dinesh Kumar, Rakesh
R, KD                       Rakesh, Kumar Dinesh
A,B,C,D&E              Apple,Ball,Cat, Dog & Egg
A78GHj                  North America

There are almost 100 codes which I need to replace.

Please note above DK, R are two codes as they are separated by comma so they will be replaced by Dinesh Kumar, Rakesh
similarly A78GHj,A78GHj will get repalced by North America, North America
0
Comment
Question by:Dinesh Kumar
[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
11 Comments
 
LVL 51

Expert Comment

by:Rgonzo1971
ID: 41870167
Hi,

Your codes are non unique:
You have A
in A,B,C,D&E              Apple,Ball,Cat, Dog & Egg
and A in
 A78GHj

I do not see how to differentiate between them

Regards
0
 
LVL 8

Expert Comment

by:Koen
ID: 41870212
@rgonzo, no he doesnt... the first code is A followed by a comma..; the second is A78GHj; -> two different codes...
1
 

Author Comment

by:Dinesh Kumar
ID: 41870234
Yes..

A,B, A78GHj

These can be considered three different codes.

to clarify more. A can be found in 2 cells so we need to replace these 2 occurrences of A separately. similarly a cell can contains 10 codes separated by comma.
0
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!

 
LVL 51

Expert Comment

by:Rgonzo1971
ID: 41870243
but when you see kd and dk  they do not have separators
0
 

Author Comment

by:Dinesh Kumar
ID: 41870350
kd and dk are two codes.
0
 

Author Comment

by:Dinesh Kumar
ID: 41870354
kd will be replaced by some string..e.g. Kumar Dinesh
0
 
LVL 22

Accepted Solution

by:
Ejgil Hedegaard earned 500 total points
ID: 41876089
Try attached.
On sheet List are the replacement list.
ID in column A, and the replacement in column B.
Add other replacements below, no empty cells in the list.
Press button to run.

It is exact character match so A is not equal to a.
ReplaceID.xlsm
0
 
LVL 45

Expert Comment

by:aikimark
ID: 41876115
Please post a sample workbook
0
 

Author Comment

by:Dinesh Kumar
ID: 41901224
I am trying the solution posted by experts.. let me update by monday next.
0
 

Author Closing Comment

by:Dinesh Kumar
ID: 41903655
perfect, thank you so much.
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

737 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