public void TargetSheetCommand(Excel.Workbook workbook, string name, ReferenceEnum referenceType = ReferenceEnum.ByName) { bool isAnInteger = int.TryParse(name, out int indexValue); if (referenceType == ReferenceEnum.ByIndex && isAnInteger == true) { workbook.ActivateSheet(indexValue); } else { workbook.ActivateSheet(name); } }