0
Try:
public static bool CellsBlank()
{
Worksheet worksheet;
Workbook wb = Global.Variables.GlobalVariables.oXL.ActiveWorkbook;
worksheet = wb.ActiveSheet;
if (worksheet != null)
{
Excel.Range cell1 = worksheet.get_Range("A2", "A2");
Excel.Range cell2 = worksheet.get_Range("A3", "A3");
if(cell1.Value2 == null && cell2.Value2 == null)
{
return true;
}
}
return false;
}
Accepted 0
Yes, except that since it's a method you need to specify the parentheses in C#:
if (CellsBlank())
Also, if you might want to test cells other than A2 and A3 , then you could pass them as parameters to the method.
0
And to check the outcome in my code I would use:
if (CellsBlank == true)
{
//run the code for when cells are blank
}
else
//run the code for when cells are NOT blank
}
Is that correct?