1

I have a macro with a variable number of players (1 and up). These players should be Player1, Player2, etc. How can I create variable names "on the fly"?

The best I can think of is something like this: a=a+1 Dim Player&(a)

1
  • 1
    Any reason for not using an array? (Dim player(1 To 10) As String: player(1) = "test1", player(2) = "test2",...) Commented Aug 15, 2015 at 18:26

1 Answer 1

2

Use Dictionary instead (treat keys as variable names): https://support.microsoft.com/en-us/kb/187234

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.