LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default dynamically increase x axis

Vicky,
if you want to try a VBA solution then something like following may do what
you want.
I have assumed that you have 3 charts on same worksheet & that sheet is
named "Sheet1" You will need to correct this as required.

Place cose in standard module - when run should update the sourcedata for
each chart:

Sub UpdateCharts()
Dim lastcol As Integer
Dim na As Integer
Dim TheChartObj As ChartObject
Dim TheChart As Chart
Dim SourceData As Range
Dim ws1 As Excel.Worksheet

'name of the worksheet where charts are stored
'change name as required
Set ws1 = ThisWorkbook.Worksheets("Sheet1")

'3 charts on same worksheet?
For na = 1 To 3

Set TheChartObj = ws1.ChartObjects(na)
Set TheChart = TheChartObj.Chart

'find last used column in row
lastcol = ws1.Cells.Rows(na + 7).Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column


Set SourceData = ws1.Range(ws1.Cells(na + 7, 2), ws1.Cells(na + 7,
lastcol))

'update sourcedata
TheChart.SetSourceData _
Source:=SourceData, _
PlotBy:=xlRows

TheChartObj.Visible = True


Set TheChartObj = Nothing
Set TheChart = Nothing

Next na

End Sub
--
jb


"vicky" wrote:

I know there have been earlier posts on this but I am new to VBA and
i am finding it difficult to find a solution for this.... i have few
charts in a sheet and its range is 1 ROW .BUT every month it keeps
increasing by 1 column. i.e if the data range for a chart is $b$7:$cm
$7 then next month it will be $b$7:$cn$7.... for all the charts in
that sheet the data range will be increased by 1 column. month is on x
axis . so charts have to get updated with every month ....... hope
anyone can give a code snippet for this.......

i.e data range for few graphs present in tat sheet

from $b$8:$cm$8 .. it will change to $b$8:$cn$8

from $b$9:$cm$9 to it will change to $b$9:$cn$9

from $b$10:$cm$10 to it will change to $b$10:$cn$10

.

 
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
Dynamically update label axis *format* without VBA? (03 and 07) ker_01 Charts and Charting in Excel 6 March 17th 10 11:59 PM
Dynamically Scale X Axis on Column Chart Based on Number of Catego Andrew Lavinsky Charts and Charting in Excel 1 February 1st 10 03:56 AM
Y Axis : Dynamically Hardcode Min/Max Values? RayportingMonkey Charts and Charting in Excel 1 February 21st 08 06:06 PM
How do I dynamically end a charts X-axis on TODAY() Azariah Charts and Charting in Excel 1 January 8th 07 08:47 PM
dynamically changing chart y axis using spin buttons and worksheet_calculate event jimnwilson Excel Programming 2 July 10th 04 04:24 AM


All times are GMT +1. The time now is 04:24 AM.

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"