View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Heliocracy Heliocracy is offline
external usenet poster
 
Posts: 29
Default Really Complicated Lookup

Thanks, I believe I can work with this. I changed the delimiter to a
semi-colon, now I just need to do some fancy text-to-column work...for which
I may need help as well lol! Any way to separate Places in each column into
their own columns, each with the same date in the first cell, and not
overwrite the columns to the right in the process?

Thanks!
Mike

"Joel" wrote:

I think this code is what you are looking for. Start with the data in sheet1
and an empty sheet2. The code will automatically put unique Dates in Row 1,
and Unique Names in column A.

Sub maketable()

Sh2Colcount = 1
Sh2Rowcount = 1
With Sheets("Sheet1")
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
For RowCount = 1 To LastRow

Mydate = .Cells(RowCount, "A").Value
Name = .Cells(RowCount, "B").Value
Place = .Cells(RowCount, "C").Value

With Sheets("Sheet2")
Set Row1Range = _
.Range(.Cells(1, "A"), _
.Cells(1, Sh2Colcount))
Set c_col = Row1Range.Find(what:=Mydate, _
LookIn:=xlValues)
If c_col Is Nothing Then
Sh2Colcount = Sh2Colcount + 1
Set c_col = .Cells(1, Sh2Colcount)
c_col.Value = Mydate
End If
Set ColARange = _
.Range(.Cells(1, "A"), _
.Cells(Sh2Rowcount, "A"))
Set c_row = ColARange.Find(what:=Name, _
LookIn:=xlValues)
If c_row Is Nothing Then
Sh2Rowcount = Sh2Rowcount + 1
Set c_row = .Cells(Sh2Rowcount, "A")
c_row.Value = Name
End If

oldPlace = .Cells(c_row.Row, c_col.Column)
If InStr(oldPlace, Place) = 0 Then
If Len(oldPlace) = 0 Then
newPlace = Place
Else
newPlace = oldPlace & "," & Place
End If
.Cells(c_row.Row, c_col.Column) = newPlace
End If
End With
Next RowCount
End With
End Sub


"Heliocracy" wrote:

I have a table set up as follows:

Date Name Place
10/2/07 Name1 Place1
10/2/07 Name1 Place1
10/3/07 Name1 Place2
10/3/07 Name1 Place3
10/3/07 Name1 Place3
10/4/07 Name2 Place1
10/4/07 Name2 Place2

I need to determine how many unique Places are listed for each Name and
Date, and place that number in a new table in which each row corresponds to a
Name, and each column B:HH corresponds to a date, and at the intersection is
the number of unique Places listed on that date for that person.

Functions are not an option, there's just too many calculations and the
thing takes hours to perform them. The list above is just an example of the
full list, which we fully expect to reach 65536 rows at some point. There
are also more than 60 different people, and 365 days in a year--it's a lot of
functions.

Thanks in advance for any ideas (even just approaches I could try) as to how
to get this done.

Mike