zakizelani
New Member
- Joined
- Mar 3, 2016
- Messages
- 25
i need some expert to help me figure out what is this code try to get me.
Code:
'LOOP 1"""""""""""""""""""""""""""""""
'set the variable for the number of rows and loop through
For x = 14 To 60
'set the room variable
Set Rm = Bws.Cells(x, 5)
'LOOP 2"""""""""""""""""""""""""""""'
'loop through column range
For Each dCell In Bws.Range(Cells(x, 6), Cells(x, 61))
If Not dCell Is Nothing Then
'set the date variable
Set Dt = Cells(11, dCell.Column)
'FIND FUNCTION""""""""""""""""""""
'find the rooms
Set aCell = orange.Find(What:=Rm, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not aCell Is Nothing Then
'set the room variable
Set bCell = aCell
'LOOP 3"""""""""""""""""""""""
'loop through the filtered data
Do
'find the next room with a booking
Set aCell = orange.FindNext(After:=aCell)
'establish the dates to add
If aCell.Offset(0, 1).Value <= Dt.Value And aCell.Offset(0, 3).Value >= Dt.Value Then
'set the variables
Set Cl = aCell.Cells(1, 4) 'status
Set Nn = aCell.Cells(1, 6) 'name
Set ID = aCell.Offset(0, -1) 'ID
'add the names and reassign after once
If oCell <> Nn Or iCell <> ID Then
dCell.Value = Nn
Set oCell = Nn
Set iCell = ID
End If
'add the coloring
Select Case Cl
Case "Outstanding"
dCell.Interior.ColorIndex = 27
Case "Missed"
dCell.Interior.ColorIndex = 24
Case "Paid & Attend"
dCell.Interior.ColorIndex = 4
Case "Unpaid & Attend"
dCell.Interior.ColorIndex = 38
End Select
End If
'exit when values are found
If Not aCell Is Nothing Then
If aCell.Address = bCell.Address Then Exit Do
Else
Exit Do
End If
' """""""""""
Loop 'LOOP 3 end
' """""""""""""""""""""""""""
End If
End If
Next dCell 'LOOP 2 end """""""""""""
Next x 'LOOP 1 end """""""""""""""
On Error GoTo 0
End Sub