Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Charts in VBA

Hi,

I have the code shown below, that creates a chart based in the data present
in sheet "Sheet_1":

Charts.Add
ActiveChart.ChartType = xlXYScatterLinesNoMarkers
ActiveChart.SetSourceData Source:= _
Sheets("Sheet_1").Range("A1:B382"), PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="Grafics"
With ActiveChart
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Charts in VBA

You need to be sure you are using the proper Sheet Object
better change to this
with Sheets("Sheet_1")
.Range(.Cells(1, 1), .Cells(rowNum, 2)),
PlotBy:=xlColumns
end with


Beware of the point before the Cells methods, indicating that you are
refering to the same sheet.

Francisco mariscal

"Rui Ãlvares" wrote:

Hi,

I have the code shown below, that creates a chart based in the data present
in sheet "Sheet_1":

Charts.Add
ActiveChart.ChartType = xlXYScatterLinesNoMarkers
ActiveChart.SetSourceData Source:= _
Sheets("Sheet_1").Range("A1:B382"), PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="Grafics"
With ActiveChart
.
. (the code positioned here don't interest for the case)
.
End With
ActiveSheet.Shapes("Chart 2").ScaleHeight 1.25, msoFalse,
msoScaleFromBottomRight

This code runs perfectly, but if I change the fourth line for the given line
(rowNum is an integar variable):

Sheets("Sheet_1").Range(Cells(1, 1), Cells(rowNum, 2)),
PlotBy:=xlColumns

the program crashes. I don't understand why this happens because in the VBA
help I found
range defined in this form. The same happesn if I change the variable rowNum
for an integer number.
Have you any idea toresolve this problem?

Thanks in advance

Rui




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
charts toolbar / charts disappeared Pro Charts and Charting in Excel 0 December 18th 09 01:31 AM
link excel charts to web pages and update charts automatically Signguy Charts and Charting in Excel 1 April 22nd 08 08:29 PM
Charts - How to have multiple charts share a legend. Sean Charts and Charting in Excel 2 November 20th 07 04:49 AM
interactive charts for stacked bar charts [email protected] Charts and Charting in Excel 4 December 28th 06 09:58 PM
Matching the colors Column Charts and Pie Charts RohanSewgobind Charts and Charting in Excel 3 April 21st 06 09:35 PM


All times are GMT +1. The time now is 03:05 AM.

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"