Help with variables

K

keri

Hi,

I have 26 subs that refer to names. However I have just remembered that
the names are on a list that can be updated.

I thought I would be able to set a global variable for each of the
names and then refer to them in my code.

This is how my sub looks at the moment;

Sheets("chart").Select
ActiveSheet.ChartObjects("CHART 32").Activate
ActiveChart.ChartArea.Select
If ActiveSheet.Range("A26") = False Then
ActiveChart.seriescollection("SMITH").Select
With Selection.Border
.LineStyle = xlNone

My question is 2 part -
1. If i define the names as name1 to 26 as global variables (type =
range), where do I set what each of these refers to? Do i do this is
the sub that refers to the range or do I do this when I am declaring
the global variables?

2. How do I refer to the variable in my code?

Eg this line currently reads....

ActiveChart.seriescollection("SMITH").Select

but instead of the name of the series collection name I need to refer
to the series collection where the name is = to the variable I have
defined as Name1

eg. Set Name1 = sheets.("names").range("a1")
 
G

Guest

I am not sure what you are asking.
If you want to set a variable from a cell, do something like this.

Dim m_Name as String
m_Name = Sheets.("names").Cells(1, 1).FormulaR1C1

I use FormulaR1C1 the most. You can use Value also.
FormulaR1C1 has string length limit
Value has no string length limit, but you may get a result of a formula
instead of the real formula.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top