Advertisement
Guest User

Untitled

a guest
Mar 31st, 2025
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. 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
  2. 'in this dictionary, the keys and the values are both the id of the orangutans
  3. 'This dictionary is modified as focal or pms are selected, to make sure the observer does not select the same individuals twice
  4.  
  5. Public ListPmDistance As Object 'This dictionary is used to store the IDs and distances of all the current active PMs selected by the observer.
  6. 'It is modified as the observer adds/removes individuals.
  7.  
  8. 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.
  9. '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
  10.  
  11. 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
  12. '(as party position remains the same thoughout the day).
  13.  
  14.  
  15. Sub InitializeDictionary()
  16. Dim wsPM As Worksheet
  17. Dim lastRow As Long
  18. Dim rng As Range, cell As Range
  19.  
  20. ' Ensure dictionaries exist
  21. If ListOrangutans Is Nothing Then Set ListOrangutans = CreateObject("Scripting.Dictionary")
  22. If ListPmDistance Is Nothing Then Set ListPmDistance = CreateObject("Scripting.Dictionary")
  23. If ListOldPmDistance Is Nothing Then Set ListOldPmDistance = CreateObject("Scripting.Dictionary")
  24. If ListPmOrder Is Nothing Then Set ListPmOrder = CreateObject("Scripting.Dictionary")
  25.  
  26. ' Set reference to the 'PM' worksheet
  27. Set wsPM = ThisWorkbook.Sheets("PM")
  28.  
  29. ' Get last row with data in column A
  30. lastRow = wsPM.Cells(wsPM.Rows.Count, 1).End(xlUp).Row
  31. Set rng = wsPM.Range("A2:A" & lastRow) ' Adjust range as needed
  32.  
  33. ' Populate the ListOrangutans dictionary (avoiding duplicates)
  34. For Each cell In rng
  35. If Not ListOrangutans.Exists(cell.Value) Then
  36. ListOrangutans.Add cell.Value, cell.Value
  37. End If
  38. Next cell
  39.  
  40. Set wsPM = Nothing
  41.  
  42. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement