Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default 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
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
can i link a variable cost code with a variable sum I need help!! Excel Discussion (Misc queries) 0 August 1st 08 11:40 AM
VBA Code - NAME SEVERAL VARIABLE cells Danny Excel Worksheet Functions 0 October 14th 05 06:15 PM
variable code?? Paul Excel Discussion (Misc queries) 1 April 5th 05 06:37 PM
How to use a variable as a sheets code name Rodney POWELL Excel Programming 0 August 25th 04 04:55 PM
Variable in a VB Code Michael Kintner Excel Programming 1 January 5th 04 02:29 PM


All times are GMT +1. The time now is 03:54 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"