Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Calculated name of variable (Any)

    Hi

    I have a timesheet macro that stores two sets of arrival and departure times for each day of the week then adds the lot up. The code is very repetitive. For example:<pre> Sat1 = FormatForDialog("Sat1")
    Sat2 = FormatForDialog("Sat2")
    Sat3 = FormatForDialog("Sat3")
    Sat4 = FormatForDialog("Sat4")
    etc, etc</pre>


    Is there any way of referring to a variable by its calculated name? Something along the lines of:<pre> For i = 1 to 4
    "Sat" & i = FormatForDialog("Sat" & i)
    Next i</pre>


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Calculated name of variable (Any)

    The argument of FormatForDialog is a string, so you can use "Sat" & i there, but you cannot refer to a variable that way, but you could create an array:

    Dim Sat(1 To 7)
    Dim i As Integer
    For i = 1 To 7
    Sat(i) = FormatForDialog("Sat" & i)
    Next i

Posting Permissions

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