Results 1 to 6 of 6

Thread: Evaluate a string as vba command??

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2011
    Posts
    7

    Evaluate a string as vba command??

    Hi,

    How can i do:
    Code:
    A = "msgbox " & chr(34) & "Hello" & chr(34)
    ProcEvaluate(A)
    and have VBA to evaluate the string A as a VBA command?

    Evaluate is a common procedure in programming languages.
    Is VBA lacking it?

    Thanks

  2. #2
    Fanatic Member dmaruca's Avatar
    Join Date
    May 2006
    Location
    Jacksonville, FL
    Posts
    577

    Re: Evaluate a string as vba command??

    Look for Application.Run

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2011
    Posts
    7

    Re: Evaluate a string as vba command??

    Thanks,

    but Application.Run seems only to run macros.

    Is there a way to run chunks of code?

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2011
    Posts
    7

    Re: Evaluate a string as vba command??

    Let me rephrase.

    Suppose you want to create variables

    A1
    A2
    A3
    An

    via FOR loops where i=1 to n

    How would you do?

  5. #5
    Fanatic Member dmaruca's Avatar
    Join Date
    May 2006
    Location
    Jacksonville, FL
    Posts
    577

    Re: Evaluate a string as vba command??

    That's really script-like. Much like languages that support syntax like "/echo {A{1}}" type expressions. VBA is not that kind of language. You'll want to use arrays and enumerations.

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Evaluate a string as vba command??

    research on callbyname
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width