0

I am not the most advanced professor when it comes into loops so I am a little bit stuck here.

Normally I would use it like:

    Dim ouLookup: Set ouLookup = CreateObject("MFilesAPI.Lookup")
    Dim ouLookups: Set ouLookups = CreateObject("MFilesAPI.Lookups")

    ouLookup.Item = ThisWorkbook.Sheets("Sheet1").Range("E1").Value
    ouLookup.Version = -1
    ouLookups.Add -1, ouLookup

    ouLookup.Item = ThisWorkbook.Sheets("Sheet1").Range("E2").Value
    ouLookup.Version = -1
    ouLookups.Add -1, ouLookup

    etc.

By this code we are adding user ID's to our collection ouLookups that we will use later in this code:

' AssignedToUsers
oPropertyValue.PropertyDef = MFBuiltInPropertyDefAssignedTo
oPropertyValue.Value.SetValueToMultiSelectLookup ouLookups ' It is here
oPropertyValues.Add -1, oPropertyValue

Is it possible to built a loop code for adding user ID's? So it will do this operation in a loop from cell E1 to E35:

    ouLookup.Item = ThisWorkbook... ' Offset or something?
    ouLookup.Version = -1
    ouLookups.Add -1, ouLookup
10101
  • 2,232
  • 3
  • 26
  • 66

1 Answers1

1

Loops are very easy, there's loads of tutorial available online. Definitely look into it :)

Here's how you can use a loop in your case

'set range
Set myrng = ThisWorkbook.Sheets("Sheet1").Range("E1:E35")

'loop through each cell in range
For Each cel In myrng
    'this is how you cna access the value
    MsgBox cel.Value
Next
Daniel
  • 814
  • 6
  • 12