Hi everybody. I was wondering if somebody out there could tell me what is
wrong with this code? I'm trying to plot a chart in excel using VB. For
this example, the value of the Index variable is 150, but it could be
anything because it is calculated earlier in the code. I can't see anything
wrong with the code myself, but it seems not to like it. Any help would be
appreciated.
Kevin
Index = 150
Charts.Add
ActiveChart.ChartType = xlXYScatterSmooth
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = Range(Cells(8, 1), Cells(Index
+ 8, 1))
ActiveChart.SeriesCollection(1).Values = Range(Cells(8, 2).Value,
Cells(Index + 8, 2)) 3 19607
Actually, here is an update to the code, I made a change. Any help is
appreciated.
Kevin
Index = 150
ActiveChart.SeriesCollection(1).XValues = Range(Cells(8, 1), Cells(Index +
8, 1))
ActiveChart.SeriesCollection(1).Values = Range(Cells(8, 2), Cells(Index + 8,
2))
"Kevin Long" <su*********@hotmail.com> wrote in message
news:Aj*********************@news20.bellglobal.com ... Hi everybody. I was wondering if somebody out there could tell me what is wrong with this code? I'm trying to plot a chart in excel using VB. For this example, the value of the Index variable is 150, but it could be anything because it is calculated earlier in the code. I can't see anything wrong with the code myself, but it seems not to like it. Any help would be appreciated.
Kevin Index = 150
Charts.Add ActiveChart.ChartType = xlXYScatterSmooth ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = Range(Cells(8, 1), Cells(Index + 8, 1)) ActiveChart.SeriesCollection(1).Values = Range(Cells(8, 2).Value, Cells(Index + 8, 2))
"Kevin Long" <su*********@hotmail.com> wrote in message
news:mV*********************@news20.bellglobal.com ...
|
| ActiveChart.SeriesCollection(1).XValues = Range(Cells(8, 1),
Cells(Index +
| 8, 1))
| ActiveChart.SeriesCollection(1).Values = Range(Cells(8, 2),
Cells(Index + 8,
| 2))
|
| "Kevin Long" <su*********@hotmail.com> wrote in message
| news:Aj*********************@news20.bellglobal.com ...
| > Hi everybody. I was wondering if somebody out there could tell me
what is
| > wrong with this code? I'm trying to plot a chart in excel using VB.
For
| > this example, the value of the Index variable is 150, but it could
be
| > anything because it is calculated earlier in the code. I can't see
| > anything wrong with the code myself, but it seems not to like it.
Any
| > help would be appreciated.
| >
| > Index = 150
| >
| > Charts.Add
| > ActiveChart.ChartType = xlXYScatterSmooth
| > ActiveChart.SeriesCollection.NewSeries
| >
| > ActiveChart.SeriesCollection(1).XValues = Range(Cells(8, 1),
| > Cells(Index + 8, 1))
| > ActiveChart.SeriesCollection(1).Values = Range(Cells(8, 2).Value,
| > Cells(Index + 8, 2))
| >
|
You are losing track of the worksheet, so the range and cell functions
are getting lost - an active chart doesn't have cells, etc.
Grabbing the correct worksheet before making the chart will fix the
problem:
Dim WS As Worksheet
Index = 150
Set WS = Worksheets("Sheet1")
Charts.Add
ActiveChart.ChartType = xlXYScatterSmooth
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = _
WS.Range(WS.Cells(8, 1), WS.Cells(Index + 8, 1))
ActiveChart.SeriesCollection(1).Values = _
WS.Range(WS.Cells(8, 2), WS.Cells(Index + 8, 2))
Worked perfectly. Thank you.
Kevin
"Steve Gerrard" <my********@comcast.net> wrote in message
news:_I********************@comcast.com... "Kevin Long" <su*********@hotmail.com> wrote in message news:mV*********************@news20.bellglobal.com ... | | ActiveChart.SeriesCollection(1).XValues = Range(Cells(8, 1), Cells(Index + | 8, 1)) | ActiveChart.SeriesCollection(1).Values = Range(Cells(8, 2), Cells(Index + 8, | 2)) | | "Kevin Long" <su*********@hotmail.com> wrote in message | news:Aj*********************@news20.bellglobal.com ... | > Hi everybody. I was wondering if somebody out there could tell me what is | > wrong with this code? I'm trying to plot a chart in excel using VB. For | > this example, the value of the Index variable is 150, but it could be | > anything because it is calculated earlier in the code. I can't see | > anything wrong with the code myself, but it seems not to like it. Any | > help would be appreciated. | > | > Index = 150 | > | > Charts.Add | > ActiveChart.ChartType = xlXYScatterSmooth | > ActiveChart.SeriesCollection.NewSeries | > | > ActiveChart.SeriesCollection(1).XValues = Range(Cells(8, 1), | > Cells(Index + 8, 1)) | > ActiveChart.SeriesCollection(1).Values = Range(Cells(8, 2).Value, | > Cells(Index + 8, 2)) | > |
You are losing track of the worksheet, so the range and cell functions are getting lost - an active chart doesn't have cells, etc.
Grabbing the correct worksheet before making the chart will fix the problem:
Dim WS As Worksheet
Index = 150
Set WS = Worksheets("Sheet1")
Charts.Add ActiveChart.ChartType = xlXYScatterSmooth ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = _ WS.Range(WS.Cells(8, 1), WS.Cells(Index + 8, 1)) ActiveChart.SeriesCollection(1).Values = _ WS.Range(WS.Cells(8, 2), WS.Cells(Index + 8, 2)) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mytfein |
last post by:
Hi Everyone,
Background:
Another department intends to ftp a .txt file from the mainframe, for me
to process.
The objective is to write a vb script that would be scheduled to run
daily to...
|
by: Matthew Wieder |
last post by:
I have the following requirements:
Build a stand-alone C# application that asks the user to click in a cell
in an Excel spreadsheet, and then displays the address of that cell in
the C#...
|
by: Mansi |
last post by:
I need to do some research on how to use excel automation from c#. Does
anyone know of any good books related to this subject?
Thanks.
Mansi
|
by: pmud |
last post by:
Hi,
I need to use an Excel Sheet in ASP.NET application so that the users can
enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever
the USER ENETRS needs to go to the...
|
by: Greg |
last post by:
Hi,
Any ideas of the syntax required to perform an Excel sort from VB.Net?
Are there any Imports statements required, etc.?
Also, if I want the data in Column B centered, I use:
| |
by: Muhammad Zeeshan Iqbal |
last post by:
Hello,
Language= Java;
Platform= Linux;
Application= Web
I have help excel file. I download it using FileInputStream.
When it is downloaded from solaris or widows platform it is correct....
|
by: elbatz |
last post by:
Hello.Does anyone here know how to convert or export data from excel to access database having an existing table using visual basic 6 codes?
And if that data in excel already exist in access...
|
by: hitencontractor |
last post by:
I am working on .NET Version 2003 making an SDI application that calls MS Excel 2003.
I added a menu item called "MyApp Help" in the end of the menu bar to show Help-> About.
The application...
|
by: andre0170 |
last post by:
Hi... well I'm stuck. I'm hoping that someone can help me identify where I'm going wrong with the macro code I'm using...I'm working on a spreadsheet that tracks purchases. When the word "Data" is...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |