0

I'm not sure how or if I can do this... I want to build the function name using "ap1", which I'm able to do, but I'm getting an "expected array" error. Thoughts? I've been staring at this too long.

Here's the piece of code:

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
2
  • 3
    I can't tell what you're trying to do. Right now it says that ap1 isn't an array, which is correct: ap1 is a string. Commented Sep 4, 2013 at 14:41
  • The strswtype value is DMS100 and then I'm adding the "_AddPort" onto it so, ap1 = "DMS100_AddPort". I'm sending the newnum0 value to a function called DMS100_AddPort. Is there a way to do that without having to set it up like: ap = DMS100_AddPort(newnum0) to send it to the function? Commented Sep 4, 2013 at 16:37

1 Answer 1

1

From your comment:

The strswtype value is DMS100 and then I'm adding the "_AddPort" onto it so, ap1 = "DMS100_AddPort". I'm sending the newnum0 value to a function called DMS100_AddPort. Is there a way to do that without having to set it up like: ap = DMS100_AddPort(newnum0) to send it to the function?

To do so, use the Application.Run method:

ap = Application.Run(ap1, newnum0)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.