Dynamic variable name?

Roderick_E

Well-known Member
Joined
Oct 13, 2007
Messages
2,051
Suppose I have undeclared variables called:
config1
config2

How can I make these dynamic in a FOR loop.

Code:
For x = 1 to 2
if [COLOR=#ff0000]"config" & x[/COLOR] = "something" then
'do something
endif
next x
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
yes, thanks I did go with an array solution:

Code:
Dim configcnt As Long
Dim configobj As Object
Set configobj = CreateObject("Scripting.Dictionary")
configcnt = 3 'change to reflect number of config elements


'---- MANUAL SETTINGS
configobj(1) = "Inland Source sheet"
configobj(2) = "Analysis sheet"
configobj(3) = "Created Inland Sheet"
'unfilter sheets if filtered
 For x = 1 To configcnt
    If Sheets(configobj(x)).AutoFilterMode Then
    Sheets(configobj(x)).Cells.AutoFilter
    End If
 Next x
 
Upvote 0

Forum statistics

Threads
1,223,270
Messages
6,171,103
Members
452,379
Latest member
IainTru

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
Back
Top