从下拉列表中选择多个项目(无重复),并从查找中求和它们的值

时间:2019-02-12 10:05:04

标签: excel vba

在工作表 const float_t* output0Ptr = outputs[0].flat<float_t>().data(); 中,我有一个单元格 Input Variable ,其中包含 multiple items selected from a drop down (without repetition),并用逗号分隔。

drop down

它们的查找值在另一张 F3 中,如下所示:

ref data

我想在单元格 Ref Data 中获得他们的总和。

G3

到目前为止,我只获得一项价值。

例如:

one item

但是当我从下拉列表中选择另一个项目时,我会得到 =VLOOKUP(F3,'Ref Data'!B:C,2,FALSE)

例如:

对于项目 #N/A ,值应为 Delivery, Pilot (1000 + 500)

multiple item

如何解决此问题?

编辑:

1500

使用答案中提到的上述功能

Function Mult_Lookup_and_Sum(strCommaSepInput As String, _
                                rngLookat As Excel.Range, _
                                lngSumCol As Long) As Double

Dim a() As String
Dim lngCounter As Long

a = Split(strCommaSepInput, ",")

Mult_Lookup_and_Sum = 0

For lngCounter = 0 To UBound(a)
    Mult_Lookup_and_Sum = Mult_Lookup_and_Sum + _
                Application.WorksheetFunction.VLookup( _
                    Trim(a(lngCounter)), rngLookat, lngSumCol)

Next lngCounter

Erase a

End Function

我收到此错误:

enter image description here

进一步检查:

enter image description here

1 个答案:

答案 0 :(得分:0)

您可以使用类似的功能。

test 1,test 2

我在A1中拥有Mult_Lookup_and_Sum(range("a1"), range("d1:e2"),2),在D1:E2中,我具有测验1的总数和测验2的总数。

所以我这样称呼,vlookup的最后一个参数与# Xcode # Build, test, and archive an Xcode workspace on macOS. # Add steps that install certificates, test, sign, and distribute an app, save build artifacts, and more: # https://docs.microsoft.com/azure/devops/pipelines/languages/xcode pool: vmImage: 'macOS-10.13' trigger: none variables: - name: SDK value: iphoneos - name: Configuration value: ReleasePPD steps: - task: DeleteFiles@1 inputs: SourceFolder: '$(system.defaultWorkingDirectory)' Contents: 'AuraApp.xcworkspace' - task: CocoaPods@0 inputs: forceRepoUpdate: false displayName: 'pod install using the CocoaPods task' - task: InstallAppleCertificate@2 inputs: certSecureFile: 'ios_distribution.p12' - task: InstallAppleProvisioningProfile@1 inputs: provisioningProfileLocation: 'secureFiles' # Options: secureFiles, sourceRepository provProfileSecureFile: 'Aura_PPD_Distribution_Profile.mobileprovision' removeProfile: true - task: Xcode@5 inputs: xcWorkspacePath: '$(system.defaultWorkingDirectory)/AuraApp.xcworkspace' actions: 'build' sdk: $(SDK) configuration: $(Configuration) xcodeVersion: '10' # Options: 8, 9, 10, default, specifyPath exportPath: '$(Build.ArtifactStagingDirectory)/PPD' packageApp: true #exportMethod: 'package' exportOptions: 'auto' #exportOptionsPlist: '' scheme: 'Aura PPD' signingOption: manual signingIdentity: $(APPLE_CERTIFICATE_SIGNING_IDENTITY) provisioningProfileUuid: $(APPLE_PROV_PROFILE_UUID) - task: AppCenterDistribute@1 inputs: serverEndpoint: 'Azure App Center' appSlug: aurafoundation/Aura appFile: $(Build.ArtifactStagingDirectory)/**/*.ipa releaseNotesOption: 'input' releaseNotesInput: 'Test' 中列号的功能相同