Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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
?
243 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

670 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