Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need Help with Dynamic Chart Worksheet Change Macro


I have the following code, but can't seem to correct the error generated
with the line that sets the source data. Can someone help me out? I
have data in columns A and B, but the # of rows vary based on a
combobox pulldown value. I would like the chart to update
automatically with the # of rows that get populated with data. Thanks
in advance for any help.

Private Sub Worksheet_Change(ByVal Target As Range)

Dim LastRow As Long
Dim MyRange As Range

LastRow = Range("A1").End(xlDown).Row
Set MyRange = Range("A1:B" & LastRow)

If Not Intersect(Target, MyRange) Is Nothing Then
ActiveSheet.ChartObjects("Chart 3").SetSourceData _
Source:=Sheets("Sheet2").Range(MyRange)
End If

End Sub


--
clmarquez
------------------------------------------------------------------------
clmarquez's Profile: http://www.excelforum.com/member.php...o&userid=29386
View this thread: http://www.excelforum.com/showthread...hreadid=500034

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Need Help with Dynamic Chart Worksheet Change Macro

Hi,

You need to alter the Source range and you also omitted the .Chart
object reference.

Private Sub Worksheet_Change(ByVal Target As Range)

Dim LastRow As Long
Dim MyRange As Range

LastRow = Range("A1").End(xlDown).Row
Set MyRange = Range("A1:B" & LastRow)

If Not Intersect(Target, MyRange) Is Nothing Then
ActiveSheet.ChartObjects("Chart 3").Chart.SetSourceData _
Source:=MyRange
End If

End Sub

Cheers
Andy

clmarquez wrote:
I have the following code, but can't seem to correct the error generated
with the line that sets the source data. Can someone help me out? I
have data in columns A and B, but the # of rows vary based on a
combobox pulldown value. I would like the chart to update
automatically with the # of rows that get populated with data. Thanks
in advance for any help.

Private Sub Worksheet_Change(ByVal Target As Range)

Dim LastRow As Long
Dim MyRange As Range

LastRow = Range("A1").End(xlDown).Row
Set MyRange = Range("A1:B" & LastRow)

If Not Intersect(Target, MyRange) Is Nothing Then
ActiveSheet.ChartObjects("Chart 3").SetSourceData _
Source:=Sheets("Sheet2").Range(MyRange)
End If

End Sub



--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need Help with Dynamic Chart Worksheet Change Macro


Thanks Andy.


--
clmarquez
------------------------------------------------------------------------
clmarquez's Profile: http://www.excelforum.com/member.php...o&userid=29386
View this thread: http://www.excelforum.com/showthread...hreadid=500034

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default Need Help with Dynamic Chart Worksheet Change Macro

It's possible to create dynamic charts without using macros. See
for example:

http://www.tushar-mehta.com/excel/ne...ynamic_charts/



clmarquez wrote:
I have the following code, but can't seem to correct the error generated
with the line that sets the source data. Can someone help me out? I
have data in columns A and B, but the # of rows vary based on a
combobox pulldown value. I would like the chart to update
automatically with the # of rows that get populated with data. Thanks
in advance for any help.

Private Sub Worksheet_Change(ByVal Target As Range)

Dim LastRow As Long
Dim MyRange As Range

LastRow = Range("A1").End(xlDown).Row
Set MyRange = Range("A1:B" & LastRow)

If Not Intersect(Target, MyRange) Is Nothing Then
ActiveSheet.ChartObjects("Chart 3").SetSourceData _
Source:=Sheets("Sheet2").Range(MyRange)
End If

End Sub


--
clmarquez
------------------------------------------------------------------------
clmarquez's Profile: http://www.excelforum.com/member.php...o&userid=29386
View this thread: http://www.excelforum.com/showthread...hreadid=500034


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
Copy worksheet with dynamic chart? [email protected][_2_] Charts and Charting in Excel 1 March 27th 09 12:07 PM
Dynamic change of chart source QM Charts and Charting in Excel 3 July 3rd 07 01:06 PM
change exist chart to be dynamic Daniel Charts and Charting in Excel 7 June 8th 07 01:50 PM
how to change range for dynamic chart in excel 2000 with button? ivan Charts and Charting in Excel 2 April 24th 05 04:10 AM
Dynamic Range Chart Macro Question GerbilGod7 Excel Programming 6 August 16th 04 12:04 PM


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