Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
variable code
Would appreciate help with what I am doing wrong.. vba
does not like the lines containing the variables for setting chart parameters: Sub last1500() Dim currentrow As Integer Dim beginrow As Integer currentrow = Worksheets("data").Range("aa1").Value beginrow = currentrow - 1500 Application.ScreenUpdating = False ActiveSheet.ChartObjects("Chart 10").Activate ActiveChart.SeriesCollection(1).Values = "=DATA! RbeginrowC5:RcurrentrowC5" ActiveChart.SeriesCollection(2).Values = "=DATA! RbeginrowC19:RcurrentrowC19" End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
variable code
"Paul" wrote in message ... Would appreciate help with what I am doing wrong.. vba does not like the lines containing the variables for setting chart parameters: Sub last1500() Dim currentrow As Integer Dim beginrow As Integer currentrow = Worksheets("data").Range("aa1").Value beginrow = currentrow - 1500 Application.ScreenUpdating = False ActiveSheet.ChartObjects("Chart 10").Activate ActiveChart.SeriesCollection(1).Values = "=DATA! RbeginrowC5:RcurrentrowC5" ActiveChart.SeriesCollection(2).Values = "=DATA! RbeginrowC19:RcurrentrowC19" End Sub Instead of "=DATA!RbeginrowC5:RcurrentrowC5" try something like this Evaluate("DATA!R" + Trim(Cstr(beginrow)) & "C5:R" & Trim(Cstr(currentrow)) & "C5") /Fredrik |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
variable code
Your varibales are snot variables if thery are part of a string. You need to
pull them out of the string something like this... ActiveChart.SeriesCollection(1).Values = "=DATA! R" & beginrow & "C5:R" & currentrow & "C5" ActiveChart.SeriesCollection(2).Values = "=DATA! R" & beginrow & "C19:R" & currentrow & "C19" HTH "Paul" wrote: Would appreciate help with what I am doing wrong.. vba does not like the lines containing the variables for setting chart parameters: Sub last1500() Dim currentrow As Integer Dim beginrow As Integer currentrow = Worksheets("data").Range("aa1").Value beginrow = currentrow - 1500 Application.ScreenUpdating = False ActiveSheet.ChartObjects("Chart 10").Activate ActiveChart.SeriesCollection(1).Values = "=DATA! RbeginrowC5:RcurrentrowC5" ActiveChart.SeriesCollection(2).Values = "=DATA! RbeginrowC19:RcurrentrowC19" End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
can i link a variable cost code with a variable sum | Excel Discussion (Misc queries) | |||
VBA Code - NAME SEVERAL VARIABLE cells | Excel Worksheet Functions | |||
variable code?? | Excel Discussion (Misc queries) | |||
How to use a variable as a sheets code name | Excel Programming | |||
Variable in a VB Code | Excel Programming |