+ Reply to Thread
Results 1 to 2 of 2

Eliminating dupes from a single cell with multiple values

  1. #1
    Registered User
    Join Date
    12-20-2013
    Location
    somewhere, Or
    MS-Off Ver
    Excel 2010
    Posts
    16

    Eliminating dupes from a single cell with multiple values

    My first hedge is, I've been tasked with a reporting job and I haven't used Excel for years. I looked up a thread from 2004 that mimics what I need and copying the code, tried to replace the code to match my sheet ranges, I'm not sure what went wrong, but I get a compiler and syntax error. so I replaced all the : ;_ - (operators) in the Names with letters.

    Would anyone be able to help me adapt the following to my attached sample xls? Forum sample.xlsx

    I need to remove dupes from columns N (TRN), O (BRO), P (APP), Q (BUS)
    the text in each multi-value cell is separated with commas.

    Currently looks like: GBTXFA110Z Ariba Indirect Procurement for Requestors,GBTXFA110Z Ariba Indirect Procurement for Requestors,GBTXFA112Z Creating and Approving Business Role Access (eLearning)

    Needs to look like: GBTXFA110Z Ariba Indirect Procurement for Requestors,GBTXFA112Z Creating and Approving Business Role Access (eLearning)



    Forum sample.xlsx

    VB
    [Option Explicit
    Sub Remove_DupesInString()
    ' this puts the final value in column m
    Dim starval As String
    Dim finval As String
    Dim strarray() As String
    Dim x As Long
    Dim TRN As Long
    ' step through each cell in range
    For Each cell(, ", ") In Sheets(1).Range("TRN")
    Erase strarray ' erase array
    finval = "" ' erase final value"
    starval = cell.Value

    strarray = Split(starval, ",")

    'Step through length of string and look for duplicate
    For rw = 0 To UBound(strarray)

    For n = rw + 1 To UBound(strarray)
    If Trim(strarray(n)) = Trim(strarray(rw)) Then
    strarray(n) = "" 'if duplicate clear array value
    End If
    Next n
    Next rw

    ' combine all value in string less duplicate
    For x = 0 To UBound(strarray)
    If strarray(x) <> "" Then

    finval = finval & Trim(strarray(x)) & ", "
    End If

    Next x
    ' remove last space and comma
    finval = Trim(finval)
    finval = Left(finval, Len(finval) - 1)
    ' output value to Column m
    cell.Offset(0, 9).Value = finval


    Next cell

    End Sub]


    Thanks,
    Trishnalynn
    Last edited by Trishnalynn; 01-08-2014 at 09:58 PM.

  2. #2
    Registered User
    Join Date
    12-20-2013
    Location
    somewhere, Or
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Eliminating dupes from a single cell with multiple values

    Previous post
    Last edited by Trishnalynn; 01-08-2014 at 10:03 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How to return multiple values to a single cell based on multiple criteria
    By lwallace in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-20-2014, 06:32 AM
  2. [SOLVED] HELP: Need to separate values from a single cell with multiple values
    By MrBrownGuy in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-24-2013, 07:46 AM
  3. Sum values from multiple cells - multiple lookup values in single cell
    By taxdept in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-21-2012, 04:12 PM
  4. Replies: 2
    Last Post: 02-20-2012, 06:06 PM
  5. Find and highlight ALL dupes in a single row
    By JP Romano in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-06-2011, 01:38 PM

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