PC Review


Reply
Thread Tools Rate Thread

Determine the last non-blank cell in a range

 
 
=?Utf-8?B?QWFyb24gRHljaw==?=
Guest
Posts: n/a
 
      26th Oct 2006
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?
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      26th Oct 2006
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determine last blank cell in row? robotman@gmail.com Microsoft Excel Worksheet Functions 8 21st May 2007 10:03 PM
Determine if range has NO Blank Cells without looping through each cell in range Excelenator Microsoft Excel Programming 4 4th Aug 2006 06:30 AM
Function to determine if any cell in a range is contained in a given cell choxio@yahoo.com Microsoft Excel Worksheet Functions 3 7th Feb 2005 04:19 PM
Re: I need to determine a cell range based on a blank cell Katrina Microsoft Excel Programming 1 3rd Jul 2003 09:11 PM
I need to determine a cell range based on a blank cell Katrina Microsoft Excel Worksheet Functions 2 3rd Jul 2003 09:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:53 PM.