Dim a string

irresistible007

Board Regular
Joined
Nov 24, 2005
Messages
173
i wanna declare a string whose name has to be whatever the user has kicked in the Text Box.... is it possible?

It comes up wid the error "Expected end of statement" (at ".") when i tried:
Dim country_name.Text as String
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Thats okay, hope the rest of it makes sense.

There is also the question of scope - what do you want to do with these variables once your procedure has finished executing? If these are declared at a module level they will lose their values at the end of the script

And its not that you cant declare a variable when you press the dim button - that would be fine - but you need to have prescribed what you want the variable to be called, and its type before the script is run. Otherwise it will not compile full stop, and you will never be able to use the script.

The only workaround as far as I know is to do what I said earlier, create an array of datatypes and simulate the assignment and instantiation of variables through it.
 
Upvote 0

Forum statistics

Threads
1,223,099
Messages
6,170,111
Members
452,302
Latest member
TaMere

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