Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Determine the last non-blank cell in a range

I have a range (called rng), and I need to determine the row number that the
last non-blank cell in this range refers to. I have the following code:

set rng=thisworkbook.sheets(1).range("A1:A65535")

There should be no non-blanks in the sheet between the first entry (in A1)
and the last entry (which I am trying to find). I need to set my counter
variable, z, to the number of records in the range.

Any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Determine the last non-blank cell in a range

msgbox application.counta(rng)

would tell you how many cells in rng have something in them.

If you wanted the lastrow that had something in it, you could use something
like:

dim LastRow as long
with thisworkbook.sheets(1)
lastrow = .cells(.rows.count,"A").end(xlup).row
end with



Aaron Dyck wrote:

I have a range (called rng), and I need to determine the row number that the
last non-blank cell in this range refers to. I have the following code:

set rng=thisworkbook.sheets(1).range("A1:A65535")

There should be no non-blanks in the sheet between the first entry (in A1)
and the last entry (which I am trying to find). I need to set my counter
variable, z, to the number of records in the range.

Any suggestions?


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determine last blank cell in row? [email protected] Excel Worksheet Functions 8 May 21st 07 10:03 PM
Determine if range has NO Blank Cells without looping through each cell in range Excelenator[_29_] Excel Programming 4 August 4th 06 06:30 AM
Determine if a cell is in a range? fedude Excel Programming 11 May 23rd 06 10:40 PM
Determine First non blank cell in col without Macro davenews Excel Programming 1 December 9th 05 12:03 PM
I need to determine a cell range based on a blank cell Katrina Excel Programming 1 July 3rd 03 09:11 PM


All times are GMT +1. The time now is 12:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"