Count blank cell in a column

  • Thread starter Thread starter shantanu
  • Start date Start date
S

shantanu

Dear All
My requirement is to count the number of cells which are
blank in a excel column, for taht i am writing the following
code;;;;;;;;;;;;;;;;;

private void ValidateReviewComment()
{
//Range xlsRng = _sheet.get_Range("G1",Type.Missing).EntireColumn;
//MessageBox.Show(xlsRng.EntireColumn.Count.ToString());
Range xlsRng = _sheet.UsedRange;
MessageBox.Show("xlsRng.Rows.Count "+xlsRng.Rows.Count.ToString());
for (int i = 2; i <= xlsRng.Rows.Count; i++)
{

if(xlsRng.Cells.Value2==null)
{
MessageBox.Show(i.ToString());
}
}
}

kindly assist me
thanks
shantanu
 
I converted your C code to VBA

Sub ValidateReviewComment()
'Range xlsRng = _sheet.get_Range("G1",Type.Missing).EntireColumn;
'MessageBox.Show(xlsRng.EntireColumn.Count.ToString());

Lastrow = Cells(Rows.Count, 1).End(xlUp).Row
Set xlsrange = Range(Cells(1, 1), Cells(Lastrow, 1))

BlankCount = 0
MsgBox ("LastRow = " & Val(Lastrow))
For Each cell In xlsrange

If IsEmpty(cell.Value) Then
BlankCount = BlankCount + 1
MsgBox ("BlankCount = " & Val(BlankCount))
End If
Next cell

End Sub
 
I converted your C code to VBA

Sub ValidateReviewComment()
'Range xlsRng = _sheet.get_Range("G1",Type.Missing).EntireColumn;
'MessageBox.Show(xlsRng.EntireColumn.Count.ToString());

Lastrow = Cells(Rows.Count, 1).End(xlUp).Row
Set xlsrange = Range(Cells(1, 1), Cells(Lastrow, 1))

BlankCount = 0
MsgBox ("LastRow = " & Val(Lastrow))
For Each cell In xlsrange

If IsEmpty(cell.Value) Then
BlankCount = BlankCount + 1
MsgBox ("BlankCount = " & Val(BlankCount))
End If
Next cell

End Sub






- Show quoted text -

sorry did not help
Thanx a lot i had the solution
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top