Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Active cell chart

Hi,

The following code updates a chart based on an active cell. In this
occasion he puts only one row into the chart. Now I would like to do
the same but then with 3 rows of data, say the line selected and the
following two rows.
Can someone tell me how to incorporate this in a code?

Thanks a lot!

Regards,
Robert


Sub UpdateChart()
Dim TheChartObj As ChartObject
Dim TheChart As Chart
Dim UserRow As Long
Dim CatTitles As Range
Dim SrcRange As Range
Dim SourceData As Range

If Sheets("Sheet1").CheckBox1 Then
Set TheChartObj = ActiveSheet.ChartObjects(1)
Set TheChart = TheChartObj.Chart
UserRow = ActiveCell.Row
If UserRow < 3 Or IsEmpty(Cells(UserRow, 1)) Then
TheChartObj.Visible = False
Else
Set CatTitles = Range("A2:W2")
Set SrcRange = Range(Cells(UserRow, 1), Cells(UserRow,
23))
Set SourceData = Union(CatTitles, SrcRange)
TheChart.SetSourceData _
Source:=SourceData, PlotBy:=xlRows
TheChartObj.Visible = True
End If
End If
End Sub
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
Row select mode to highlight active row of active cell Bart Fay[_2_] Excel Discussion (Misc queries) 0 May 11th 10 09:34 PM
run macro although blinking cursor is active in an active cell bartman1980 Excel Programming 1 December 20th 07 11:29 AM
how do i make a chart follow the active cell mepetey Charts and Charting in Excel 2 October 20th 07 07:29 PM
referring to formula in a non active cell from active cell nickname Excel Discussion (Misc queries) 1 June 21st 07 12:11 PM
I need to sort an active sheet using the col of the active cell HamFlyer Excel Programming 3 June 6th 06 07:25 PM


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