gingerafro
Active Member
- Joined
- Mar 23, 2005
- Messages
- 448
I have a very large data set (about 450k rows) of hotels with a price for each day for a whole year.
I have put them in a pivot table with dates down the left and hotels across the top. price is obviously the data field.
I want to show for each day of the year, which hotel is the cheapest by highlighting it. I have tried running a macro and the basics of it are below.
Sub dateselect()
Dim d As PivotItem
Dim b As PivotItem
With Worksheets("Sheet1").PivotTables("PivotTable5")
For Each d In .PivotFields("START DATE").PivotItems
For Each b In .PivotFields("NIGHT PRICE (MKT CURR)").PivotItems
If b = Min(d) Then
.PivotItems(b).Font.Color = 2
End If
Next
Next
End With
End Sub
If I was doing this manually, I would look down at each date then look across to find the cheapest price. I had hoped my macro would do it, but my VBA writing is a bit 'pigeon'.
I have put them in a pivot table with dates down the left and hotels across the top. price is obviously the data field.
I want to show for each day of the year, which hotel is the cheapest by highlighting it. I have tried running a macro and the basics of it are below.
Sub dateselect()
Dim d As PivotItem
Dim b As PivotItem
With Worksheets("Sheet1").PivotTables("PivotTable5")
For Each d In .PivotFields("START DATE").PivotItems
For Each b In .PivotFields("NIGHT PRICE (MKT CURR)").PivotItems
If b = Min(d) Then
.PivotItems(b).Font.Color = 2
End If
Next
Next
End With
End Sub
If I was doing this manually, I would look down at each date then look across to find the cheapest price. I had hoped my macro would do it, but my VBA writing is a bit 'pigeon'.