Incremental Variable Names

FIFARay007

Board Regular
Joined
Jan 7, 2008
Messages
111
Quick question....

I'm using a For...Next loop and was hoping I could use it to change the variable name as well. What I have is below...

Code:
    For i = 1 To 11
        
        opt & i = EssVGetGlobalOption(i)
      
        
    Next i

What I'd like is to populate "opt1", "opt2", "opt3", etc. with the results of that function. Is this possible?
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

iggydarsa

Well-known Member
Joined
Jun 28, 2005
Messages
1,734
Office Version
  1. 2019
Platform
  1. Windows
creating a variable of ARRAY would be a more logical solution
 
Upvote 0

iggydarsa

Well-known Member
Joined
Jun 28, 2005
Messages
1,734
Office Version
  1. 2019
Platform
  1. Windows
if you are not familiar with arrays, this might give you an idea

Code:
Sub test()
Dim x(3) As Integer 'Create an array that can hold 3 integer values

'Populate the array with 10, 20, and 30
For i = 1 To 3
    x(i) = i * 10
Next i

'Display the values one by one
For i = 1 To 3
    MsgBox x(i)
Next i
End Sub

also, you can do a little research within this forum for more valuable information
 
Upvote 0

Forum statistics

Threads
1,191,706
Messages
5,988,187
Members
440,136
Latest member
dandanfielding

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top