Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Automated charting VB code problem

Hi Dan,

Try the folowing

rng3 = "I" + Str(T1) + ":" + "I" + Str(T2)

change to
rng3 = "I" & T1 & ":" & "I" & T2

The Str function provides a leading space for the +- sign.

regards,
Don

"Danimal " wrote in message
...
Hi,

I am trying to write code to automatically create a series of charts
using difference data when the macro is run. I am having a problem
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 a
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 the
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 causing
the problem, how do I get rid of these spaces??? Any other ideas on
defining the range? I tried to use Range(Cells(T1,9),Cells(T2,9)), but
it did not work either...

Thanks in advance,
Dan


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



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
Zero problem with blank cell after automated data transfer Struggling in Sheffield[_2_] New Users to Excel 2 November 13th 09 12:41 PM
CHARTING CODE ERROR Jase Excel Discussion (Misc queries) 6 April 11th 08 07:32 PM
Why doesn't Excel 2007 record charting and office art macro code? NOLuckMatt Excel Discussion (Misc queries) 0 August 17th 07 02:38 PM
Automated graph problem danmck Excel Discussion (Misc queries) 0 March 7th 07 06:51 PM
Precision problem with automated formula fill-in Erny Meyer Excel Worksheet Functions 1 February 4th 05 01:22 PM


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