So I have this spreadsheet, it has Fname, Lname, Pnumber, Email, Cid. Cid is the only really important one, the rest are optional technically.
So instead of just doing a loop to see when the cell values starts being null, I know you can use the
WorksheetFunction.CountA(some 30 different variable that I do not understand but are optional too);
to get the actual numbers of filled cells, and it is instant. I have no idea how to do this.
This is what I'm going to do viva looping, but I know the CountA() function can do it in one line.
int i = 1;
while (i <= 200)
{
cell = (Microsoft.Office.Interop.Excel.Range)worksheet.Cells[i, 5];
if (cell.Value2 > 0)
{i++;}
else
{break;}
}
int totalCol = i;
Ok, this is what I have now, thanks everyone.
var cell = (Microsoft.Office.Interop.Excel.Range)worksheet.Cells[1, 1];
cell.Formula = "=CountA(E1:E200)";
double totalCells = (cell.Value2) -1;
I'm not in the IDE right now, but this should do the trick:
Dim cl As Microsoft.Office.Interop.Excel.Range
cl.Formula = "=CountA(E1:E200)"
myVal = cl.Value