DIFFERENT VARIABLES

chebapuc

New Member
Joined
Apr 4, 2006
Messages
18
Hi. I need to take an unknown number of variables from a list for using them in a next step of a macro. The code needs only to travel across a column in the file and to save a variable (var1, var2, var3...) for each change in the name.
Please, help!!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Yes... I think that that is the answer... the problem is that I don't know how to do it... Thanks!
 
Upvote 0
Something like this perhaps:

Code:
Sub test()
Dim t, x As Integer
t = Range("A1:E1")
For x = 1 To 5
    MsgBox t(1, x)
Next
End Sub
 
Upvote 0
Yes, but the problem is that I don't know the real range, I only know tht the array will find the variable names in the C column... and want it to save with the names (t1, t2, t3... ???) this names. BR
 
Upvote 0
There is a problem with your code...
I need to have the variable names somewhere to use them
Your code shows me only the name of the first one and then an error...
 
Upvote 0
There isn't a problem with my code:

First variable is row, second column, you specified in your original post that you were going across columns, not down rows.

In my example:
t(1,1) is the value in A1
t(1,2) is the value in B1
t(1,3) is the value in C1
t(1,4) is the value in D1
t(1,5) is the value in E1

But this doesn't sound like what you are trying to do.
What are these variable names you are referring to?
 
Upvote 0
Thanks. The fact is that I must take variable names to work with them in an other process. Then, I must name the firts one as (f.ex) var1, the second var2, etc. The problems are that:
1) The number of variables can change, and for a file can be 3 and in the next can be 10
2) The variables are repeted in the column, then, when the name of variable 1 is in A1, the variable 2 can be in A14 and the variable 3 in A150 maybe... the only thing I know is that the variables are in alphabetical order, so I need the macro to travel across the column and asign var1 to the first name, var2 to the second, etc.

This is the table where I'm working:

Range("A:A") is:
BORMIOLI
BORMIOLI
BORMIOLI
BORMIOLI
CALP
CALP
CHURCHILL
CHURCHILL
CHURCHILL
CHURCHILL

etc...

And I need:
var1 = BORMIOLI
var2 = CALP
var3 = CHURCHILL

Thanks!!
 
Upvote 0
That's just not going to be possible.:)

You can't create variables dynamically in that way, if at all.

What you probably need is an array.

But that's hard to tell since you've not actually told us what you want to do with these values.

There could be other solutions. eg advanced filter, a collection.

PS I don't really think that you go across a column, surely you go down it.:)
 
Upvote 0
OK. This is:

I'm working with products of different brands. I download once a day from an internet site the sells of these products from my costumer B2B. Every days sells are of different products and I need to make a report with the sells where I must to put in each page of an Excel file each brand and inside the products of each brand.
So, I need to have my variables (may be an array) named as the brands to name with them the pages and filter the products I put in each page.
Thank you very much for your time!!!
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

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