Thanks for the quick response. Here is the function:
Function DayList(ID As Integer, LookUp As Range)
Dim DayOfWeek(7) As Boolean
Dim lData As Integer, lFree As Integer, DayBinary As Integer
Dim DayOfWeekInc As Long
Dim QueryCell As Object
Dim DayLetters As String, DayListString As String, QueryWorksheet As String
DayListString = "": DayLetters = "MTWTFSS"
QueryWorksheet = "Weekly Breakdown (" + Format(ID) + ")"
With Worksheets(QueryWorksheet)
For Each QueryCell In LookUp
If .Cells(QueryCell.Row, 2) = 1 Then
lData = QueryCell.Value
If lData <> 0 Then
DayBinary = 1
For DayOfWeekInc = 1 To 7
If lData And DayBinary Then DayOfWeek(DayOfWeekInc) = True
DayBinary = DayBinary * 2
Next
End If
End If
Next
End With
For DayOfWeekInc = 1 To 7
If DayOfWeek(DayOfWeekInc) = True Then
DayListString = DayListString + Mid(DayLetters, DayOfWeekInc, 1)
Else
DayListString = DayListString + "*"
End If
Next
DayList = DayListString
End Function
This is called by:
=IF($J10<>"",DayList(1,'Weekly Breakdown (1)'!$BE$4:$BE$73),"")
The background to this spreadsheet is a long story, but basically enables an orchestra member to view the impact of a combination of projects on their working week. The function listed above displays which days of the week they will be working on, and changes dynamically when the user changes the projects they may wish to work on.
The line of sheet code is repeated once for each year week, calling a different range on the 'Weekly Breakdown (x)' sheet each time.