Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an application that generates reports. These reports are .xls file template that get data from data.csv file.Whenever I am making changes in the vb script. for bar chart of one of the .xls workbook(that contains 2 sheets, sheet 1(sheet 1 fetches data from csv) and sheet 2(It contains logic for the data) )Now Iam adding a function in the script that displays chart in sheet 3.

Sub Create_Bar_Chart()
'create a bar chart in excel with this macro

ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("'Sheet3'!$A$1:$B$67")
ActiveChart.ChartType = xlBarClustered

End Sub
This script is generating chart.

But In sheet one data gets added... means the columns that were taken as template are moved from column 1 to column 60 .. and column 1 to column 59 values are added with new data,but from 60 columns old data also present ..and the backgroud colors and template is also moved from 60 to so onward.

Question is that why sheet 1 values are adding instead of just updating with new values rather shifting to new columns.

What I have tried:

Sub Create_Bar_Chart()
'create a bar chart in excel with this macro

ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("'Sheet3'!$A$1:$B$67")
ActiveChart.ChartType = xlBarClustered

End Sub
This script is generating chart.

But In sheet one data gets added... means the columns that were taken as template are moved from column 1 to column 60 .. and column 1 to column 59 values are added with new data,but from 60 columns old data also present ..and the backgroud colors and template is also moved from 60 to so onward.

Question is that why sheet 1 values are adding instead of just updating with new values rather shifting to new columns.
Posted
Updated 10-Mar-16 19:15pm

1 solution

Quote:
Question is that why sheet 1 values are adding instead of just updating with new values rather shifting to new columns.
Because the code for chart generate an event that launch another piece of code (unlisted) that result in what you say.
Since you play with events, one need the WorkBook (Excel file) to track down what append exactly. I am getting paid for this kind of stuff.
Resolution of this is beyond the scope of this forum.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900