The macro below opens up an excel workbook and builds a chart on the provided data. I would like to add some error handling so that in the event an excel workbook named differently to the one specified (Employee_source_data) is provided then a message box is displayed e.g Please ensure spreadsheet name provided is "Employee_source_data". Any ideas how to accomplish this? Thanks in advance!
Sub GenerateEmployeeReport()
Workbooks.Open Filename:=ThisWorkbook.Path & "\Employee_source_data"
Range("E2").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-3]:RC[-1])"
Selection.AutoFill Destination:=Range("E2:E7"), Type:=xlFillDefault
Range("E2:E7").Select
Range("A1:A7,E1:E7").Select
Range("E1").Activate
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range( _
"'Sheet2'!$A$1:$A$7,'Sheet2'!$E$1:$E$7")
ActiveChart.ChartType = xl3DColumnClustered
End Sub
InStr()orStrComp()to verify if one string exists within the other.