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.Cha rtType = xlXYScatterSmoo th
ActiveChart.Ser iesCollection.N ewSeries
ActiveChart.Ser iesCollection(1 ).XValues = Range(Cells(8, 1), Cells(Index
+ 8, 1))
ActiveChart.Ser iesCollection(1 ).Values = Range(Cells(8, 2).Value,
Cells(Index + 8, 2)) 3 19614
Actually, here is an update to the code, I made a change. Any help is
appreciated.
Kevin
Index = 150
ActiveChart.Ser iesCollection(1 ).XValues = Range(Cells(8, 1), Cells(Index +
8, 1))
ActiveChart.Ser iesCollection(1 ).Values = Range(Cells(8, 2), Cells(Index + 8,
2))
"Kevin Long" <su*********@ho tmail.com> wrote in message
news:Aj******** *************@n ews20.bellgloba l.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.Cha rtType = xlXYScatterSmoo th ActiveChart.Ser iesCollection.N ewSeries
ActiveChart.Ser iesCollection(1 ).XValues = Range(Cells(8, 1), Cells(Index + 8, 1)) ActiveChart.Ser iesCollection(1 ).Values = Range(Cells(8, 2).Value, Cells(Index + 8, 2))
"Kevin Long" <su*********@ho tmail.com> wrote in message
news:mV******** *************@n ews20.bellgloba l.com...
|
| ActiveChart.Ser iesCollection(1 ).XValues = Range(Cells(8, 1),
Cells(Index +
| 8, 1))
| ActiveChart.Ser iesCollection(1 ).Values = Range(Cells(8, 2),
Cells(Index + 8,
| 2))
|
| "Kevin Long" <su*********@ho tmail.com> wrote in message
| news:Aj******** *************@n ews20.bellgloba l.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.Cha rtType = xlXYScatterSmoo th
| > ActiveChart.Ser iesCollection.N ewSeries
| >
| > ActiveChart.Ser iesCollection(1 ).XValues = Range(Cells(8, 1),
| > Cells(Index + 8, 1))
| > ActiveChart.Ser iesCollection(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("She et1")
Charts.Add
ActiveChart.Cha rtType = xlXYScatterSmoo th
ActiveChart.Ser iesCollection.N ewSeries
ActiveChart.Ser iesCollection(1 ).XValues = _
WS.Range(WS.Cel ls(8, 1), WS.Cells(Index + 8, 1))
ActiveChart.Ser iesCollection(1 ).Values = _
WS.Range(WS.Cel ls(8, 2), WS.Cells(Index + 8, 2))
Worked perfectly. Thank you.
Kevin
"Steve Gerrard" <my********@com cast.net> wrote in message
news:_I******** ************@co mcast.com... "Kevin Long" <su*********@ho tmail.com> wrote in message news:mV******** *************@n ews20.bellgloba l.com... | | ActiveChart.Ser iesCollection(1 ).XValues = Range(Cells(8, 1), Cells(Index + | 8, 1)) | ActiveChart.Ser iesCollection(1 ).Values = Range(Cells(8, 2), Cells(Index + 8, | 2)) | | "Kevin Long" <su*********@ho tmail.com> wrote in message | news:Aj******** *************@n ews20.bellgloba l.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.Cha rtType = xlXYScatterSmoo th | > ActiveChart.Ser iesCollection.N ewSeries | > | > ActiveChart.Ser iesCollection(1 ).XValues = Range(Cells(8, 1), | > Cells(Index + 8, 1)) | > ActiveChart.Ser iesCollection(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("She et1")
Charts.Add ActiveChart.Cha rtType = xlXYScatterSmoo th ActiveChart.Ser iesCollection.N ewSeries
ActiveChart.Ser iesCollection(1 ).XValues = _ WS.Range(WS.Cel ls(8, 1), WS.Cells(Index + 8, 1)) ActiveChart.Ser iesCollection(1 ).Values = _ WS.Range(WS.Cel ls(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 process this .txt file.
Goal:
I am working on a vba script 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# application. It seems simple enough, but the problem I'm
encountering is as follows:
In order for the user to select the cell from Excel, they must first...
|
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 SQL DATABASE, probably by the click of a
button.
Is this possible? & what is the BEST APPROACH for doing this? & also if any
links are there do...
|
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.
But when it is downloaded from Linum platform it becomes corrupted.
|
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 database it should not be inserted or maybe the old records be replaced.plss help me.i do not know how to code it.it's urgent..thanks a lot..
|
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 calls MS Excel, so the scenario is that I am supposed to see the Excel Menu bar,
FILE EDIT VIEW INSERT ... HELP.
I am able to see the menu bar, but in...
|
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 listed in Column B of sheet 1 (Instruments_TradeCalc), I want to have the values of four cells in the same row copied from Sheet1...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |