Solved

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

Posted on 2013-01-08
3
221 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

839 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