Problem Related to drag chart in Excel

prince
2StarLounger
Posts: 171
Joined: 02 Mar 2015, 17:00

Problem Related to drag chart in Excel

Post by prince »

Hello Sir, When i drag the group of 27 rows then the Chart in excel not showing to display the update record. Kindly guide me how can i see the new record when i drag the group of rows.
Kindly see the sheet 2 where i have tried to data through the chart. But its not going update during the drag.
With Regards,
Prince
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78671
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Problem Related to drag chart in Excel

Post by HansV »

As you have found, the source data of a chart aren't changed when you copy the chart. You will have to edit the source data for each chart separately.
- Select a chart.
- On the Design tab of the ribbon (under Chart Tools), in the Data group, click Select Data.
- Select the correct data range.
S1039.png
- Click OK.
- Repeat for each chart.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Problem Related to drag chart in Excel

Post by Rudi »

If you have lots of charts, you can try this macro.

Code: Select all

Sub SetChartData()
Dim oCh As ChartObject
Dim rgA As Range
Dim r As Long
    Application.ScreenUpdating = False
    For Each oCh In ActiveSheet.ChartObjects
        Set rgA = oCh.TopLeftCell
        r = rgA.Row
        Set rgA = Range("B" & r - 4 & ":C" & r - 2)
        oCh.Chart.SetSourceData Source:=rgA
    Next
    Application.ScreenUpdating = True
End Sub
The macro gets the cell reference of the top left corner of the chart and calculates the location by moving 4 rows up and getting the reference in columns B and C.
It then sets the source range of the chart with the newly calculated range.
Needless to say that it relies wholly on the fact that the data structure remains a similar structure, but that should be the case if you are auto-filling the blocks each time.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

prince
2StarLounger
Posts: 171
Joined: 02 Mar 2015, 17:00

Re: Problem Related to drag chart in Excel

Post by prince »

Mr. Rudi , wat an idea ! its working perfectly . Thanks a lot .
Mr. Hans , you have also suggested the good idea. Thanks to you also.
With Regards,
Prince

prince
2StarLounger
Posts: 171
Joined: 02 Mar 2015, 17:00

Re: Problem Related to drag chart in Excel

Post by prince »

Mr. Rudi, Yesterday i was tried you macro code & it was working perfectly but when i opened this file again now its not working . what i do now . Kindly suggest me.
Regards,
Prince

User avatar
HansV
Administrator
Posts: 78671
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Problem Related to drag chart in Excel

Post by HansV »

Have you changed the layout of your sheet?

Do you get an error message? If so what does it say?
Best wishes,
Hans

prince
2StarLounger
Posts: 171
Joined: 02 Mar 2015, 17:00

Re: Problem Related to drag chart in Excel

Post by prince »

No Mr. Hans , I got the solution now. Actually each and every time when i will drag the group of rows after that when i will run the macro code then it showing the effects on sheet.
Thanks for communication Mr. Hans.
Regards,
Prince