Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Help with variables

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")

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Help with variables

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.

"keri" wrote:

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")


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not at all clear on use of variables and/or object variables JMay-Rke Excel Discussion (Misc queries) 11 July 4th 08 06:36 PM
Min of 2 variables Ed Excel Programming 5 November 20th 06 06:09 PM
Variables Mike Excel Programming 1 November 25th 05 06:59 PM
Variables Kelford Excel Programming 2 June 2nd 05 01:14 PM
Variables Phil Excel Programming 1 April 15th 05 04:39 PM


All times are GMT +1. The time now is 11:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"