View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
sycsummit sycsummit is offline
external usenet poster
 
Posts: 21
Default Eliminating repeats from a list

Thanks for the direction... I get the concept. But, I am unfamiliar with
this language and syntax!

How would I have to change your code if I wanted to read the whole list of
names from a worksheet titled "NEW", from cells J1 through J25 -- and paste
them in a worksheet called "Billing", as my list of one of each name,
starting with cell A5?

"Rick Rothstein (MVP - VB)" wrote:

This response works with my code... I did not check it against the other
postings. If you are not already in the VB editor, press Alt+F11 from any
worksheet to go there. Once there, click on Insert/Module from the VB editor
menu bar and then Copy/Paste my code (repeated here for your convenience)

Sub MoveUniqueNames()
Dim X As Long
Dim Z As Long
Dim UniqueNames As String
UniqueNames = "*"
Z = 1
With Worksheets("Sheet1")
For X = 1 To .Cells(.Rows.Count, "A").End(xlUp).Row
If InStr(UniqueNames, "*" & .Cells(X, "A").Value & "*") = 0 Then
UniqueNames = UniqueNames & .Cells(X, "A").Value & "*"
Worksheets("Sheet4").Cells(Z, "A").Value = .Cells(X, "A").Value
Z = Z + 1
End If
Next
End With
End Sub

into the code window that opened there. You can execute the code from any
worksheet, but my guess is you will want to be in Sheet2 (where my code
places the unique names that are listed in Sheet1 starting at Column A, Row
1) in order to see the list being produced; so, go to Sheet2 and then press
Alt+F8 and select MoveUniqueNames from the list, then click on Run. You
should see the unique names listed on Sheet2 starting at Column A, Row 1.

Rick


"sycsummit" wrote in message
...
All of these responses look impressive, but I was hoping there would be a
more simple solution, such as a function I may have overlooked... anything
that would let me type "=(formula)" in the cell and be done with it.

I can work with this though... but where do you put this? How do I input
this stuff into my spreadsheet?


"Rick Rothstein (MVP - VB)" wrote:

I believe this macro will do what you want...

Sub MoveUniqueNames()
Dim X As Long
Dim Z As Long
Dim UniqueNames As String
UniqueNames = "*"
Z = 1
With Worksheets("Sheet1")
For X = 1 To .Cells(.Rows.Count, "A").End(xlUp).Row
If InStr(UniqueNames, "*" & .Cells(X, "A").Value & "*") = 0 Then
UniqueNames = UniqueNames & .Cells(X, "A").Value & "*"
Worksheets("Sheet2").Cells(Z, "A").Value = .Cells(X, "A").Value
Z = Z + 1
End If
Next
End With
End Sub

It assumes the worksheet with your original (repeated) name list is
Sheet1
(in Column A starting at Row 1) and the worksheet you want to put the
unique
name list on is Sheet2 (into Column A starting at Row 1).

Rick


"sycsummit" wrote in message
...
I am using Excel 2003. I am working with a list of names of various
people,
in one column. I need to have this list reproduced on a blank
worksheet
with
the repeated names removed.

for instance, the list I'm working with would be something like:
Pat
Pat
Dan
Marie
Marie
Sharron
Sharron
Sharron
Sharron
Daniel
Mark
Mark
Mark
Mark

...and I would need this list to be reproduced on another tab as:
Pat
Dan
Marie
Sharron
Daniel
Mark

Is there a way I can do this?