Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello and greetings.

I hope this will be a simple question for most but is causing me grief.

 

I am trying to find out the number of rows in an Excel spreadsheet.

I am using vb.net. The code compiles beautifully but everytime I run the program it returns the row number to be 1. I know there are more than 1 rows on this spreadsheet. What am I doing wrong.

 

Here is part of my code

 

msgbox (ws.UsedRange.Rows.Count) ' just so I see how many rows are returned

 

For i = 1 to ws.UsedRange.Rows.Count

'then I loop through the rows to get a specific column

next i

 

Thanks

 

mjay

Posted
find out the number of rows in an Excel spreadsheet

The number of rows in an Excel spreadsheet is always 65,536... I assume you are actually trying to get the number of used rows?

 

UsedRange might return a single row if you enter data only in, say, cell A5 and don't touch A1:A4 (no formatting, no data). Rows 1 to 4 would then not count as used.

 

Have you checked ws.UsedRange.Address - does that offer any clues?

Have you checked that ws is the right worksheet?

 

For any more specific help, I think you'll have to post a sample workbook that's causing trouble, and more of the code that you're using.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...