Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Finding the End of a Range

Hi there,

Is it possible using code to find the bottom of a range in say column A

tia BigH


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Finding the End of a Range



--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"BigH" wrote in message
...
Hi there,

Is it possible using code to find the bottom of a range in say column A

tia BigH




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Finding the End of a Range

Sure

LastCell = Range("A1").End(xlDown)

assuminmg there are no embedded blank cells

LastCell = Range("A" & Rows.Count).End(xlUp)

if there might be

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"BigH" wrote in message
...
Hi there,

Is it possible using code to find the bottom of a range in say column A

tia BigH






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Finding the End of a Range

I bet Bob meant:

Dim LastCell as Range
set LastCell = Range("A1").End(xlDown)
'assuminmg there are no embedded blank cells
set LastCell = Range("A" & Rows.Count).End(xlUp)

Bob Phillips wrote:

Sure

LastCell = Range("A1").End(xlDown)

assuminmg there are no embedded blank cells

LastCell = Range("A" & Rows.Count).End(xlUp)

if there might be

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"BigH" wrote in message
...
Hi there,

Is it possible using code to find the bottom of a range in say column A

tia BigH



--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding the End of a Range


Bob's example will find the end of range provided, as he pointed out,
there are are no blank lines with in the range. This is a good approach
if you know where your range starts.

Dave's example is commonly used to find the last cell within in a
column. This is not the same as Bob's example as you can have multiple
ranges within a column with each separated by one or more blank lines.


Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=514205



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Finding the End of a Range

Actually, the only difference between Bob's original code and my changes is that
I added the Dim statement. And I added Set to each of the assignment lines.

Bob included both options--he just had a typo and forgot to use Set.

Leith Ross wrote:

Bob's example will find the end of range provided, as he pointed out,
there are are no blank lines with in the range. This is a good approach
if you know where your range starts.

Dave's example is commonly used to find the last cell within in a
column. This is not the same as Bob's example as you can have multiple
ranges within a column with each separated by one or more blank lines.

Sincerely,
Leith Ross

--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=514205


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Finding the End of a Range

This is weird, I cannot see my post in here, nor Leith's. I can see Dave's
and Patrick's, and the OP, but no more. See it all fin in Google. Odd!

Bob

"Dave Peterson" wrote in message
...
Actually, the only difference between Bob's original code and my changes

is that
I added the Dim statement. And I added Set to each of the assignment

lines.

Bob included both options--he just had a typo and forgot to use Set.

Leith Ross wrote:

Bob's example will find the end of range provided, as he pointed out,
there are are no blank lines with in the range. This is a good approach
if you know where your range starts.

Dave's example is commonly used to find the last cell within in a
column. This is not the same as Bob's example as you can have multiple
ranges within a column with each separated by one or more blank lines.

Sincerely,
Leith Ross

--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile:

http://www.excelforum.com/member.php...o&userid=18465
View this thread:

http://www.excelforum.com/showthread...hreadid=514205

--

Dave Peterson



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Finding the End of a Range

here is another alternative
Sub check()
Dim here As Range
Dim lastcell As Range
Set here = Selection.CurrentRegion
Set lastcell = Cells(here.Row + here.Rows.Count - 1, here.Column +
here.Columns.Count - 1)

lastcell.Select

End Sub

"BigH" wrote:

Hi there,

Is it possible using code to find the bottom of a range in say column A

tia BigH



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
Finding the corresponding value in a range? Zuo Excel Worksheet Functions 4 February 25th 10 12:45 PM
Finding a value associated with a range Raymond Gallegos Excel Worksheet Functions 5 November 25th 05 08:38 PM
finding if name within range sheila Excel Worksheet Functions 9 September 13th 05 04:24 AM
Finding a Range Name James Montgomery Excel Programming 3 November 1st 04 06:16 PM
Finding from a range Mark[_50_] Excel Programming 1 August 26th 04 12:19 PM


All times are GMT +1. The time now is 01:53 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"