Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Charting / July 2006

Tip: Looking for answers? Try searching our database.

Remove old month from chart add new/no manual reference change

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kameel - 19 Jul 2006 02:59 GMT
jan feb mar apr
10 20   30   40

I want to graph the latest 4 months without having to go in a change
refrences in the chart each month.

Next month
feb mar apr may
20   30   40  50

If I drag the last months across to pick up the formulas for the next month
I get 5 months on the graph instead of 4
Muhammed Rafeek M - 19 Jul 2006 05:06 GMT
Hi Kameel
Its possible only.

Example:
First Row months (A1: Jan, B1: Feb,…..)
Second Row values (A2: 10, B2: 20,…..)
Put any column (eg. K10) this function:
=ADDRESS(1,COUNTA(A1:AA1)-3)&":"&ADDRESS(2,COUNTA(A1:AA1))
You will get the cell address of new four months.
Click Insert–>Name–>Define
Enter “CName” in ‘Names in workbook’ field
Refers to area: =INDIRECT(Sheet1!$K$10)
Then click OK.
Open Visual Basic Editor (Alt+F11)
Go particular sheet object area
Paste below mentioned code

‘VB Code
Dim tmpBC As String
Private Sub Worksheet_Activate()
   tmpBC = Range("K10").Value
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
   If tmpBC <> Range("K10").Value Then
       Call Refesh_Chart
   End If
End Sub

Private Sub Refesh_Chart()
Application.ScreenUpdating = False
   ActiveSheet.ChartObjects("Chart 4").Activate 'put your chart name
   ActiveChart.ChartArea.Select
   Dim rng As Range
   Set rng = Range("Cname")
       ActiveChart.SetSourceData Source:=rng, PlotBy:= _
       xlRows
       Range("A1").Select
Application.ScreenUpdating = True
End Sub

If you are not able to understand please mail to mohdraf@hotmail.com with
sample file

Thanks and regards
Muhammed Rafeek M

> jan feb mar apr
> 10 20   30   40
[quoted text clipped - 8 lines]
> If I drag the last months across to pick up the formulas for the next month
> I get 5 months on the graph instead of 4
Tushar Mehta - 21 Jul 2006 13:39 GMT
> jan feb mar apr
> 10 20   30   40
[quoted text clipped - 8 lines]
> If I drag the last months across to pick up the formulas for the next month
> I get 5 months on the graph instead of 4

See
Dynamic Charts
http://www.tushar-mehta.com/excel/newsgroups/dynamic_charts/index.html
particularly, example 2.

Signature

Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.