By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,490 Members | 1,328 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,490 IT Pros & Developers. It's quick & easy.

count the number of cells which are blank in a excel column

P: n/a
Dear All
My requirement is to count the number of cells which are
blank in a excel column, for that 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

Apr 3 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Shantanu,

The Value property of the Range instance (for each individual cell)
should be null, or a Missing value. Either way, when you iterate through
the used cells in the column, it should stick out instantly when you look at
the value in the debugger.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"shantanu" <sh***********@gmail.comwrote in message
news:11**********************@n76g2000hsh.googlegr oups.com...
Dear All
My requirement is to count the number of cells which are
blank in a excel column, for that 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

Apr 3 '07 #2

P: n/a
On Apr 3, 8:13 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Shantanu,

The Value property of the Range instance (for each individual cell)
should be null, or a Missing value. Either way, when you iterate through
the used cells in the column, it should stick out instantly when you look at
the value in the debugger.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"shantanu" <shantanuse...@gmail.comwrote in message

news:11**********************@n76g2000hsh.googlegr oups.com...
Dear All
My requirement is to count the number of cells which are
blank in a excel column, for that 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- Hide quoted text -

- Show quoted text -
Thanx a lot i had the solution

Apr 5 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.