Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Please Help With Chart Code


Hi. I am using Excel 2003.

I used the macro recorder and modied some of the code in the hopes tha
the
VBA I wrote work work. Instead, it produces errors. I have a Char
object on
a Sheet that I wish to "feed" a range to chart. Since the number o
rows for the
needed range changes from time to time, I included a variable calle
amtrows.
Then I try to "assign" a range to variable XTemp. Then I try to fee
that XTemp
range into the Chart object.

My modified code errors at this line --

Set XTemp = Range("C1").Resize(x, 0)

And at this line as well --

ActiveChart.SetSourceData Source:=Sheets("Sheet5").Range(XTemp), PlotB
_
:=xlColumns

Could you please review my code below and tell me what to change ?
would be most
grateful for your help.

WayneK

Dim amtrows As Long
Dim XTemp As Range

amtrows = Range("A8").Value

Set XTemp = Range("C1").Resize(x, 0)

ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.ChartArea.Select
ActiveChart.SetSourceData Source:=Sheets("Sheet5").Range(XTemp), PlotB
_
:=xlColumns
ActiveWindow.Visible = Fals

--
Wayne
-----------------------------------------------------------------------
WayneK's Profile: http://www.excelforum.com/member.php...fo&userid=2303
View this thread: http://www.excelforum.com/showthread.php?threadid=39417

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Please Help With Chart Code


Does anyone have any ideas towards a solution ?

Thank you.

Wayne

--
Wayne
-----------------------------------------------------------------------
WayneK's Profile: http://www.excelforum.com/member.php...fo&userid=2303
View this thread: http://www.excelforum.com/showthread.php?threadid=39417

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Please Help With Chart Code

Hi Wayne,

Have a look at this line -

Set XTemp = Range("C1").Resize(x, 0)

Resize requires the row & column arguments each to be at least 1. Both yours
are 0, as you have not assigned a value to x.

You say "amtrows" is required but it's not used in your code.

Subject to setting XTemp to a cell range that works with your chart type the
rest of your code should work, but no need to select the chartarea.

Regards,
Peter T

"WayneK" wrote in
message ...

Hi. I am using Excel 2003.

I used the macro recorder and modied some of the code in the hopes that
the
VBA I wrote work work. Instead, it produces errors. I have a Chart
object on
a Sheet that I wish to "feed" a range to chart. Since the number of
rows for the
needed range changes from time to time, I included a variable called
amtrows.
Then I try to "assign" a range to variable XTemp. Then I try to feed
that XTemp
range into the Chart object.

My modified code errors at this line --

Set XTemp = Range("C1").Resize(x, 0)

And at this line as well --

ActiveChart.SetSourceData Source:=Sheets("Sheet5").Range(XTemp), PlotBy
_
:=xlColumns

Could you please review my code below and tell me what to change ? I
would be most
grateful for your help.

WayneK

Dim amtrows As Long
Dim XTemp As Range

amtrows = Range("A8").Value

Set XTemp = Range("C1").Resize(x, 0)

ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.ChartArea.Select
ActiveChart.SetSourceData Source:=Sheets("Sheet5").Range(XTemp), PlotBy
_
:=xlColumns
ActiveWindow.Visible = False


--
WayneK
------------------------------------------------------------------------
WayneK's Profile:

http://www.excelforum.com/member.php...o&userid=23037
View this thread: http://www.excelforum.com/showthread...hreadid=394173



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
Chart Object VB Code MS[_2_] Charts and Charting in Excel 2 March 6th 07 11:41 AM
how to delete a chart using code? pwermuth[_6_] Excel Programming 4 July 13th 05 02:35 AM
Help with following code creating chart Vince Excel Programming 2 June 22nd 05 12:44 AM
Code to copy chart Helen Trim Excel Programming 0 July 16th 03 01:59 PM
Code to copy chart Pedro[_4_] Excel Programming 1 July 16th 03 01:22 PM


All times are GMT +1. The time now is 03:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"