Solved

a macro that select one by one a string from a column and compare with another column....?

Posted on 2013-01-08
3
196 Views
Last Modified: 2013-01-09
i need a macro that select one by one (from cells of column "B" in a sheet called "BIC" ) a string and compare with another cells of data in another column "F" that is in another sheet called "DFG"
and replace the cells of the "F" column on "DFG" with cells of another column "A" in a sheet called "BIC"
 "A"  & "B" column on sheet "BIC" &       "F" on sheet "DFG"      final result sheet"DFG"
10............      A.C.RYAN ............................... ACER ..................................   15
15 ...........      ACER......................................  AEE     ...............................   25
20 ..........       ADJ ....................................... FGHJ ...................................     ?
25...........      AEE ......................................  AEG  ..................................   30
30...........      AEG  ..................................... AEG   .................................   30
35...........      AIRTIES  ................................ JHGF .................................   45
40..........   ERTYU  ...............................  AIRTIES ................................35
45............ JHGF   ....................................AEG       ................................ 30
 ..............................................................ERTYU  ..............................  40
 ...............................................................ADJ                                       20

MACRO STOP WHEN FINDS EMPTY CELL IN  "B" COLUMN IN "BIC" SHEET
SUMMARY 1 WORKSHEET , 2 SHEETS , 3 COLUMNS FOR SYNC,COMPARE, REPLACE , 5000 ROWS OF DATA

THANKS EVERYBODY THAT HELPS
0
Comment
Question by:tonyantony
  • 2
3 Comments
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 38757463
yes this should be easy enough but please upload a sample workbook as it may be a lot easier to use a lookup.

is sheet(BIC) column B always sorted alphabetically ?

How do you tell the end of columns in sheet(DFG)
0
 
LVL 32

Accepted Solution

by:
Robberbaron (robr) earned 300 total points
ID: 38757573
Sub FixRef1()
    
    Dim rSrc As Range
    Dim rDest As Range
    'THIS IS SLOW WAY OF DOING IT
    'but ok for a one off
    
    Set rSrc = Worksheets("BIC").Range("B1") '<<hardcoded
    
    Do While rSrc.Value <> ""
        'proces the dest column
        Set rDest = Worksheets("DFG").Range("F1")  '<<hardcoded
        
        Do While rDest.Value <> ""
            If rDest.Value = rSrc.Value Then
                'replace with code number from column to left
                rDest.Value = rSrc.Offset(0, -1).Value
            End If
            Set rDest = rDest.Offset(1, 0)  'the next row of dest
        Loop
        
        Set rSrc = rSrc.Offset(1, 0)  'the next row
    Loop

End Sub

Open in new window

update-codenum.xls
0
 

Author Closing Comment

by:tonyantony
ID: 38761153
my best ,in 10 seconds i finish 3hours , many thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

757 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

17 Experts available now in Live!

Get 1:1 Help Now