Private Sub UserForm_Initialize()
Dim myCol As Long, x
With Sheets("schedule").[b2].CurrentRegion
myCol = Application.Match(CLng(Date), .Rows(1), 0)
If IsError(myCol) Then Exit Sub
x = Filter(.Parent.Evaluate("transpose(if((row(" & .Address & ")>2)*(" & .Columns(myCol).Address & _
"<>""OFF""),row(1:" & .Rows.Count & "),char(2)))"), Chr(2), 0)
If UBound(x) > -1 Then
Me.ListBox1.List = Application.Index(.Value, Application.Transpose(x), Array(1, 2, myCol))
End If
End With
End Sub
One way
Code:Private Sub UserForm_Initialize() Dim myCol As Long, x With Sheets("schedule").[b2].CurrentRegion myCol = Application.Match(CLng(Date), .Rows(1), 0) If IsError(myCol) Then Exit Sub x = Filter(.Parent.Evaluate("transpose(if((row(" & .Address & ")>2)*(" & .Columns(myCol).Address & _ "<>""OFF""),row(1:" & .Rows.Count & "),char(2)))"), Chr(2), 0) If UBound(x) > -1 Then Me.ListBox1.List = Application.Index(.Value, Application.Transpose(x), Array(1, 2, myCol)) End If End With End Sub