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!!
 

Some videos you may like

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

chebapuc

New Member
Joined
Apr 4, 2006
Messages
18
Yes... I think that that is the answer... the problem is that I don't know how to do it... Thanks!
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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
 

chebapuc

New Member
Joined
Apr 4, 2006
Messages
18

ADVERTISEMENT

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
 

chebapuc

New Member
Joined
Apr 4, 2006
Messages
18
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...
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows

ADVERTISEMENT

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?
 

chebapuc

New Member
Joined
Apr 4, 2006
Messages
18
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!!
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,218
Office Version
  1. 365
Platform
  1. Windows
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.:)
 

chebapuc

New Member
Joined
Apr 4, 2006
Messages
18
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!!!
 

Watch MrExcel Video

Forum statistics

Threads
1,122,575
Messages
5,596,950
Members
414,114
Latest member
Lost_User21

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