Thread: another lookup!
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Cecilkumara Fernando[_2_] Cecilkumara Fernando[_2_] is offline
external usenet poster
 
Posts: 93
Default another lookup!

arjcvg,
This macro will do it.
provided that there is no repeated Menu item for single date.
Assumed that Date column has real dates (excel dates)
Data is in "Sheet1" starting from cell A1 with headers in row 1.
there is an empty sheet "Sheet2" in the workbook.
The data can be sorted.

Run the macro from "Sheet1"

Cecil

Sub Report()
Dim i As Long
Dim j As Long
Dim k As Long
Dim LR As Long
Dim LRUM As Long
Dim l As String
Dim Rng As String
LR = Range("A" & Rows.Count).End(xlUp).Row
Range("A1:F" & LR).Sort Key1:=Range("A2"), _
Order1:=xlAscending, Key2:=Range("B2"), _
Order2:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Sheets("Sheet2").Select
Sheets("Sheet1").Range("A1:A" & LR).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=Range("A2"), Unique:=True
LRUM = Range("A" & Rows.Count).End(xlUp).Row
Range("A2:A" & LRUM).Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteAll, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=True
Range("A1").Select
Application.CutCopyMode = False
Selection.ClearContents
Sheets("Sheet1").Range("B1:B101").AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=Range("A1"), Unique:=True
LRUM = Range("A" & Rows.Count).End(xlUp).Row
Rng = Range("A1:A" & LRUM).Address
j = 2
For i = 2 To LR
If Sheets("Sheet1").Range("A" & i).Value < Cells(1, j).Value _
Then j = j + 1
l = Sheets("Sheet1").Range("B" & i).Value
k = Evaluate("Match(" & Chr(34) & l & Chr(34) & "," & _
Rng & ",0)")
Cells(k, j).Value = Sheets("Sheet1").Range("C" & i).Value
Next i
End Sub


"arjcvg " wrote in message
...
Hi Guys!

How about this:


For example, I have the following data:
DATE---MENU---TIMEAVAILABLE
8/1-----Coke----5AM-2PM
8/1-----Spag----6AM-5PM
8/2-----Coke----8PM-9PM
8/2-----Spag----10AM-6PM

How can I print a report that looks like this:

MENU-------8/1-------------8/2
Coke--------5AM-2PM------8PM-9PM
SpaG--------6AM-5PM------10AM-6PM

Thanks a lot again for your help!


---
Message posted from http://www.ExcelForum.com/