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

x
?
Solved

VBA replace kind of macro

Posted on 2016-11-02
11
Medium Priority
?
66 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 53

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 9

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
Industry Leaders: 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 53

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 23

Accepted Solution

by:
Ejgil Hedegaard earned 2000 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 46

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

Independent Software Vendors: 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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

650 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