Felix18807
Programmer
Im trying to create a chart based on the selection. See code below.
The following line is causing a data mismatch error.
Code:
Dim objExcel As Excel.Application
Set objExcel = New Excel.Application
objExcel.Visible = False
objExcel.Workbooks.Open (Me.txtDirectory)
objExcel.Cells.Find(What:="date/time of last account table update", After:= _
objExcel.ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
objExcel.ActiveCell.Offset(0, 1).select
objExcel.selection.NumberFormat = "dd/mm/yyyy hh:mm:ss"
objExcel.ActiveCell.Offset(-1, 0).Range("A1").select
objExcel.Range(selection, Cells(1)).select
objExcel.Range("A2:B7").select
objExcel.ActiveSheet.Shapes.AddChart.select
objExcel.ActiveChart.ChartType = xl3DPie
objExcel.ActiveChart.SetSourceData Source:=objExcel.selection
objExcel.ActiveChart.ClearToMatchStyle
objExcel.ActiveChart.ChartStyle = 43
The following line is causing a data mismatch error.
Code:
objExcel.ActiveChart.SetSourceData Source:=objExcel.selection