Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Not at all clear on use of variables and/or object variables | Excel Discussion (Misc queries) | |||
Min of 2 variables | Excel Programming | |||
Variables | Excel Programming | |||
Variables | Excel Programming | |||
Variables | Excel Programming |