VBA replace kind of macro

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
Dinesh KumarAsked:
Who is Participating?
 
Ejgil HedegaardCommented:
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
 
Rgonzo1971Commented:
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
 
KoenChange and Transition ManagerCommented:
@rgonzo, no he doesnt... the first code is A followed by a comma..; the second is A78GHj; -> two different codes...
1
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
Dinesh KumarAuthor Commented:
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
 
Rgonzo1971Commented:
but when you see kd and dk  they do not have separators
0
 
Dinesh KumarAuthor Commented:
kd and dk are two codes.
0
 
Dinesh KumarAuthor Commented:
kd will be replaced by some string..e.g. Kumar Dinesh
0
 
aikimarkCommented:
Please post a sample workbook
0
 
Dinesh KumarAuthor Commented:
I am trying the solution posted by experts.. let me update by monday next.
0
 
Dinesh KumarAuthor Commented:
perfect, thank you so much.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.