We need a program that uses VBA to enter data into an Excel sheet and then displays a line chart. Office version is 2013.
I found a number of examples on the Internet, but could not get any of them to work properly. This may be due in part to differences in the many versions of Excel.
The following is one of multiple programs that I have tried without success:
Set objXL = CreateObject("Excel.application")
Set objBook = objXL.Workbooks.Add
'Set a reference to Sheet1
Set objSheet = objBook.Worksheets.Item(1)
Charts.Add
'Set the dummy data range for the chart
ActiveChart.SetSourceData Sheets("Sheet1").Range("a1:d4"), PlotBy:=xlColumns
ActiveChart.ChartType = xlLineMarkers
'Manually set the values for the data series
ActiveChart.SeriesCollection(1).Formula = "=SERIES(""First Data"",{""a"",""b"",""c"",""d""},{2,3,4,5},1)"
ActiveChart.SeriesCollection(2).Formula = "=SERIES(""Second Data-"",{""a"",""b"",""c"",""d""},{6,7,8,9},2)"
ActiveChart.SeriesCollection(3).Formula = "=SERIES(""Third Data"",{""a"",""b"",""c"",""d""},{10,11,12,13},3)"
' Make Excel Visible:
objXL.Visible = True
objXL.UserControl = True
Thank you very much for your assistance.
I found a number of examples on the Internet, but could not get any of them to work properly. This may be due in part to differences in the many versions of Excel.
The following is one of multiple programs that I have tried without success:
Set objXL = CreateObject("Excel.application")
Set objBook = objXL.Workbooks.Add
'Set a reference to Sheet1
Set objSheet = objBook.Worksheets.Item(1)
Charts.Add
'Set the dummy data range for the chart
ActiveChart.SetSourceData Sheets("Sheet1").Range("a1:d4"), PlotBy:=xlColumns
ActiveChart.ChartType = xlLineMarkers
'Manually set the values for the data series
ActiveChart.SeriesCollection(1).Formula = "=SERIES(""First Data"",{""a"",""b"",""c"",""d""},{2,3,4,5},1)"
ActiveChart.SeriesCollection(2).Formula = "=SERIES(""Second Data-"",{""a"",""b"",""c"",""d""},{6,7,8,9},2)"
ActiveChart.SeriesCollection(3).Formula = "=SERIES(""Third Data"",{""a"",""b"",""c"",""d""},{10,11,12,13},3)"
' Make Excel Visible:
objXL.Visible = True
objXL.UserControl = True
Thank you very much for your assistance.