0

当涉及到循环时,我不是最先进的教授,所以我有点卡在这里。

通常我会像这样使用它:

    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.

通过这段代码,我们将用户 ID 添加到我们ouLookups稍后将在此代码中使用的集合中:

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

是否可以构建一个循环代码来添加用户 ID?因此它将在从单元格E1到的循环中执行此操作E35

    ouLookup.Item = ThisWorkbook... ' Offset or something?
    ouLookup.Version = -1
    ouLookups.Add -1, ouLookup
4

1 回答 1

1

循环很简单,网上有很多教程。一定要调查一下:)

这是在您的案例中使用循环的方法

'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
于 2019-10-04T10:50:48.617 回答