need to understand what is this code trying to do

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
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
You have some code here and you do not know what it does. And you want us to explain to you in detail what it does.

Why not tell us what you want to do and maybe we can provide some code to do what you want.
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top