+ Reply to Thread
Results 1 to 5 of 5

change old id's(values) with new id's

Hybrid View

  1. #1
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: change old id's(values) with new id's

    I had to add a little user-defined function to your workbook to do some of this:

    Function LookupReplace(sSourceString As String, rngLookup As Range, lLookUpCol As Long, Optional sDelimiter As String = ",") As String
    
    Dim vValues As Variant
    Dim lLoop As Long
    Dim vLUResult As Variant
    
    vValues = Split(sSourceString, sDelimiter)
    
    For lLoop = LBound(vValues) To UBound(vValues)
       vLUResult = Application.VLookup(Val(vValues(lLoop)), rngLookup, lLookUpCol, 0)
       If Not IsError(vLUResult) Then
         vValues(lLoop) = vLUResult
       End If
    Next lLoop
    
    LookupReplace = Join(vValues, sDelimiter)
    
    End Function
    But with that in a module I could use the formula:

    =LookupReplace(SUBSTITUTE(TRIM(SUBSTITUTE(Blad2!J2,"#"," "))," ",","),Blad1!$A$2:$B$5,2)

    In cell K2 of the results sheet, and just drag it down.

  2. #2
    Registered User
    Join Date
    04-07-2011
    Location
    Gent, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    38

    Re: change old id's(values) with new id's

    Great!!!! I can't believe you made something so quick!!!

    I just tried it and it seems to work. I'm really happy :-)

    Since I'm using a dutch version of Excel I had to change the function names in dutch and replace the comma's with semicomma's.
    So for other dutch ppl around this the formula in dutch (all credit still goes to Andrew!!!!):
    =LookupReplace(SUBSTITUEREN(SPATIES.WISSEN(SUBSTITUEREN(Blad2!J2;"###";","));" ";";");Blad1!$A$2:$B$5;2)
    As you can see I also changed the part where you substitute # into a space.
    I forgot to say that it was ### that had to be replaced into a comma and not one #. My mistake but was easily fixed by changing it into SUBSTITUEREN(Blad2!J2;"###";",")

    Thank you Andrew! You made my day!!!!!!!!!!

    Do you think it would be difficult to make it do it automatically with a button so no dragging is needed?
    The reason I ask this, is because the sheet has around 4100 rows if I'm not mistaken.


    I'm still happy that this works.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1