Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public ListOrangutans As Object ' This dictionary is used to store the IDs of all the SUAQ orangutans, using all the names in the 'PM' sheets
- 'in this dictionary, the keys and the values are both the id of the orangutans
- 'This dictionary is modified as focal or pms are selected, to make sure the observer does not select the same individuals twice
- Public ListPmDistance As Object 'This dictionary is used to store the IDs and distances of all the current active PMs selected by the observer.
- 'It is modified as the observer adds/removes individuals.
- Public ListOldPmDistance As Object 'This dictionary is used to store the IDs and distances of all the PMs selected by the observer during the previous interval.
- 'It is used to compared the previous pm distances with the current pm distances; if a distance is different, it triggers the 'partyMemberActorForm' to be filled by the observer
- Public ListPmOrder As Object 'This dictionary is used to store the IDs and party position of all the PMs selected byt the observer across the day
- '(as party position remains the same thoughout the day).
- Sub InitializeDictionary()
- Dim wsPM As Worksheet
- Dim lastRow As Long
- Dim rng As Range, cell As Range
- ' Ensure dictionaries exist
- If ListOrangutans Is Nothing Then Set ListOrangutans = CreateObject("Scripting.Dictionary")
- If ListPmDistance Is Nothing Then Set ListPmDistance = CreateObject("Scripting.Dictionary")
- If ListOldPmDistance Is Nothing Then Set ListOldPmDistance = CreateObject("Scripting.Dictionary")
- If ListPmOrder Is Nothing Then Set ListPmOrder = CreateObject("Scripting.Dictionary")
- ' Set reference to the 'PM' worksheet
- Set wsPM = ThisWorkbook.Sheets("PM")
- ' Get last row with data in column A
- lastRow = wsPM.Cells(wsPM.Rows.Count, 1).End(xlUp).Row
- Set rng = wsPM.Range("A2:A" & lastRow) ' Adjust range as needed
- ' Populate the ListOrangutans dictionary (avoiding duplicates)
- For Each cell In rng
- If Not ListOrangutans.Exists(cell.Value) Then
- ListOrangutans.Add cell.Value, cell.Value
- End If
- Next cell
- Set wsPM = Nothing
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement