• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Find and Replace from One Sheet to another VBA

Hi,
I need a macro to Find and Replace strings from One Sheet to another.
ie,
Sheet2 (master) : Column A contain string that i want to find in Sheet1 and replace with the values given in Columns B
Sheet1: Column A will contain identical string from row 1 to myLastRow. Each cell will contain string found in Sheet2 (master), column A. I want to replace this string
with values from Sheet2 (master).
Note:
find and replace first whole word and then single word, Sample file attached for your reference..
example:
CARBON STEEL : CS
CARBON : CARBN
STEEL: : STL
 

Attachments

  • Sample-abbreviation.xlsx
    11.5 KB · Views: 7
Hi, according to your attachment and the Macro Recorder :​
Code:
Sub Demo1()
    Dim V, R&
    V = Sheet2.[A1].CurrentRegion
    For R = 2 To UBound(V):  Sheet1.UsedRange.Columns(2).Replace V(R, 1), V(R, 2), 2:  Next
End Sub
Do you like it ? So thanks to click on bottom right Like !​
 
Thanks sir,
But i need one more modification..ie find and replace first whole words (combination of words) and then single word, Sample file attached for your reference..
Could you help me to resolve it..
example:
CARBON STEEL : CS
CARBON : CARBN
STEEL: : STL
 
So you must well order your list with words combinations before single words obviously …​
 
Yes sir.but master file in alphabetical order and Stainless steel (Combination word) abbreviated as SS correctly..But Carbon steel not abbreviated.
then How to resolve this sir?
 
Back
Top