Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-01-08
3
Medium Priority
?
245 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 1200 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

971 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