Hi
I have chart as shown in attached file. It plots 12 months data.
I want to restrict it to plot only such number of months as is mentioned in Cell H1.
Thank you
Hi
I have chart as shown in attached file. It plots 12 months data.
I want to restrict it to plot only such number of months as is mentioned in Cell H1.
Thank you
Is there no solution to this problem?![]()
This may work for this one..
![]()
Private Sub Worksheet_Change(ByVal Target As Range) Dim lR As Long Dim rng1, rng2 As String If Not Intersect(Target, Range("H1")) Is Nothing Then lR = CLng(Range("H1").Value) + 2 rng1 = Range(Cells(5, 2), Cells(7, lR)).Address rng2 = Range(Cells(10, 2), Cells(10, lR)).Address ActiveSheet.ChartObjects(1).Activate ActiveChart.SetSourceData Source:=Range(rng1, rng2) Range("H1").Select End If End Sub
Thank you Gerard, it works superbly but I want to move the cells H1 to some other sheet, say sheet xyz.
Then what will be change in the code
put this in the sheet you want to make the choise (H1 in this case)
![]()
Private Sub Worksheet_Change(ByVal Target As Range) Dim lR As Long Dim rng1, rng2 As String If Not Intersect(Target, Range("H1")) Is Nothing Then Application.ScreenUpdating = False lR = CLng(Range("H1").Value) + 2 With Sheets("Yearly") .Activate rng1 = Range(Cells(5, 2), Cells(7, lR)).Address rng2 = Range(Cells(10, 2), Cells(10, lR)).Address ActiveSheet.ChartObjects(1).Activate ActiveChart.SetSourceData Source:=Sheets("Yearly").Range(rng1, rng2) .Cells(1, 1).Select End With Sheets("xyz").Activate Application.ScreenUpdating = True End If End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks