Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 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

16 Experts available now in Live!

Get 1:1 Help Now