Way to make range the whole spreadsheet

B

BGCSOCAL

I'm working on VS 2005 with Excel 2003. I need to set the range for the
entire sheet, but I do not know the number of rows in use for the
spreadsheet. I tried this:
oRng = oSheet.Range("A1").EntireColumn
TotRows = oRng.Count
TotRows ended up 65,5xx. Not useful. I really don't need to set a range, I
just need to know how many rows are being used. I need to programmatically
scan down the first column to see if a particular string is there and if it
is go process the next 5 rows or so. To do this, I need the total number of
rows in use. Shoulod I just give up and search all 65K rows?

Does anyone know how to do this?
 
C

Chip Pearson

UsedRows = oSheet.UsedRange.Rows.Count

will usually do it, although from time to time Excel forgets what the
used range really is. You force it with

oSheet.UsedRange
UsedRows = oSheet.UsedRange.Rows.Count

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
B

BGCSOCAL

Mega Thanks! Can you recommend a good article about this Excel programming
Excel 2003 and 2007? The one I have may be from VS2003 or earlier!
 

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

Top