Results 1 to 4 of 4

Thread: removing dups in a single field using switch?

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    41

    removing dups in a single field using switch?

    I have a list of data and columns c,d, and e have all unique data. however some companies have more than one entry, and their name appears sometimes 8 times. I want to eliminate all but the topmost company name from t he dups. I'm assuming I need a switch statement, but I'm not sure. any ideas?

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: removing dups in a single field using switch?

    you just want to remove their name from the cell, but not the whole row?

    can you attach a sample sheet?

    pete

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    41

    Re: removing dups in a single field using switch?

    didn't realize uploading was enabled....sweeeeet.

    here's an example; i've highlighted in red what I mean should be deleted. I recenty figured out that a Switch statement is actually called Select in VB.
    Attached Files Attached Files

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: removing dups in a single field using switch?

    this code does not search the whole sheet for duplicates, only if they are grouped together
    VB Code:
    1. Sub test()
    2. Dim mystr As String, i As Integer
    3. mystr = Cells(1, 2)
    4. For i = 2 To Sheet1.UsedRange.Rows.Count
    5.     If Cells(i, 2) = mystr Then Cells(i, 2) = ""
    6.     If Not Cells(i, 2) = "" Then mystr = Cells(i, 2)
    7. Next
    8.  
    9. End Sub
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width