我不确定如何或者如果我能做到这一点...我想使用“ap1”构建函数名,我能够做到,但是我得到了一个“预期的数组”错误。思考?我一直在盯着这个。
这是一段代码:
Dim ap As Range
Dim newnum0 As String
Dim ap1 As Variant
Dim strswprog as string
dim strswtype as string
If strswprog = "Add PORT" Then
ap1 = strswtype & "_AddPort"
For Each ap In newrange
If ap > 0 Then
newnum0 = ap
ap = ap1(newnum0) 'Here's the problem
ap.Value = newnum0
End If
Next ap
End if
答案 0 :(得分:1)
来自你的评论:
strswtype值为DMS100,然后我添加" _AddPort"到 这样,ap1 =" DMS100_AddPort"。我将newnum0值发送给a 函数称为DMS100_AddPort。有没有办法做到这一点没有 必须将其设置为:ap = DMS100_AddPort(newnum0)将其发送到 功能?
为此,请使用Application.Run方法:
ap = Application.Run(ap1, newnum0)