// Macro result
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SetSourceData Source:=Range("Trd_NM!$A$2:$AC$7")
ActiveChart.SetSourceData Source:=Range("Trd_NM!$A$2:$AD$7")
<//C# code Excel.Workbook xlWorkBook; Excel._Worksheet sheet; Excel.ChartObject chartObj; Excel._Chart chart; Excel.Series series; object useDefault = Type.Missing; Excel.Workbook book; xlWorkBook = app.Workbooks.Open(@"E:\\te\\DT");//Open the work book sheet = xlWorkBook.Sheets["Trd_NM"];//Select the sheet the chart is on chart = sheet.ChartObjects("Chart 1").chart; chart.PlotArea.Select(); chart.SetSourceData(sheet.Range["A2:A6""], Excel.XlRowCol.xlColumns);>
//C# code
Excel.Workbook xlWorkBook;
Excel._Worksheet sheet;
Excel.ChartObject chartObj;
Excel._Chart chart;
Excel.Series series;
object useDefault = Type.Missing;
Excel.Workbook book;
xlWorkBook = app.Workbooks.Open(@"E:\\te\\DT");//Open the work book
sheet = xlWorkBook.Sheets["Trd_NM"];//Select the sheet the chart is on
chart = sheet.ChartObjects("Chart 1").chart;
chart.PlotArea.Select();
chart.SetSourceData(sheet.Range["A2:A6""], Excel.XlRowCol.xlColumns);