View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Danimal Danimal is offline
external usenet poster
 
Posts: 1
Default Automated charting VB code problem

Hi,

I am trying to write code to automatically create a series of chart
using difference data when the macro is run. I am having a proble
defining the chart ranges in the macro...

This code works, using a static range:
rng2 = "I2:I42"
ActiveChart.SetSourceData Source:=Sheets("All").Range(rng2), _
PlotBy:=xlColumns

But when I try to build the range string using the code below, I get
runtime error 1004:
T1 = 2
T2 = 42
rng3 = "I" + Str(T1) + ":" + "I" + Str(T2)
ActiveChart.SetSourceData Source:=Sheets("All").Range(rng3), _
PlotBy:=xlColumns

Looking at the differences of rng2 and rng3, the watch shows th
following:
rng2 "I2:I42" Type: Variant/String
rng3 "I 2:I 42" Type: Variant/String

I think the spaces in rng3 between the I's and the numbers are causin
the problem, how do I get rid of these spaces??? Any other ideas o
defining the range? I tried to use Range(Cells(T1,9),Cells(T2,9)), bu
it did not work either...

Thanks in advance,
Da

--
Message posted from http://www.ExcelForum.com