Solved

VBA replace kind of macro

Posted on 2016-11-02
11
42 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
11 Comments
 
LVL 48

Expert Comment

by:Rgonzo1971
Comment Utility
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
Comment Utility
@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
Comment Utility
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
 
LVL 48

Expert Comment

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

Author Comment

by:Dinesh Kumar
Comment Utility
kd and dk are two codes.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:Dinesh Kumar
Comment Utility
kd will be replaced by some string..e.g. Kumar Dinesh
0
 
LVL 21

Accepted Solution

by:
Ejgil Hedegaard earned 500 total points
Comment Utility
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
Comment Utility
Please post a sample workbook
0
 

Author Comment

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

Author Closing Comment

by:Dinesh Kumar
Comment Utility
perfect, thank you so much.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now