Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Find last used row in Range with Data above and below.


Hi,
I have a named range of cells D19:D1000 (EntryAreaProposal). There i
data above this range and below this range. I want to find the las
used row within this range and of course if I use something like:

LastRow = wks2.Cells(Rows.Count, "D").End(xlUp).Row

it hits the data below my range and give me "that" last row instead o
what I need. I know this has to be simple, but it's worn me out tryin
to find something in the archives.
Help please

--
Case

-----------------------------------------------------------------------
Casey's Profile: http://www.excelforum.com/member.php...nfo&userid=454
View this thread: http://www.excelforum.com/showthread.php?threadid=51700

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Find last used row in Range with Data above and below.

Give this a try...

Sub LastCell()
Dim rng As Range

With Range("EntryAreaProposal")
Set rng = Cells(.Item(1).Row + .Rows.Count,
..Column).End(xlUp).Offset(1, 0)
End With
MsgBox rng.Address
End Sub
--
HTH...

Jim Thomlinson


"Casey" wrote:


Hi,
I have a named range of cells D19:D1000 (EntryAreaProposal). There is
data above this range and below this range. I want to find the last
used row within this range and of course if I use something like:

LastRow = wks2.Cells(Rows.Count, "D").End(xlUp).Row

it hits the data below my range and give me "that" last row instead of
what I need. I know this has to be simple, but it's worn me out trying
to find something in the archives.
Help please.


--
Casey


------------------------------------------------------------------------
Casey's Profile: http://www.excelforum.com/member.php...fo&userid=4545
View this thread: http://www.excelforum.com/showthread...hreadid=517002


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Find last used row in Range with Data above and below.

How about:


Sub Macro1()
Dim s As Range
Dim i As Long
For i = 1000 To 19 Step -1
If IsEmpty(Cells(i, "D")) Then
Else
LastRow = i
Exit For
End If
Next
MsgBox (i)
End Sub
--
Gary''s Student


"Casey" wrote:


Hi,
I have a named range of cells D19:D1000 (EntryAreaProposal). There is
data above this range and below this range. I want to find the last
used row within this range and of course if I use something like:

LastRow = wks2.Cells(Rows.Count, "D").End(xlUp).Row

it hits the data below my range and give me "that" last row instead of
what I need. I know this has to be simple, but it's worn me out trying
to find something in the archives.
Help please.


--
Casey


------------------------------------------------------------------------
Casey's Profile: http://www.excelforum.com/member.php...fo&userid=4545
View this thread: http://www.excelforum.com/showthread...hreadid=517002


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Find last used row in Range with Data above and below.


Jim and Gary's Student,
Thank you both for the bits of code. I'm going to try Jim's first
because it makes use of the Named Range. But I really appreciate the
reply from both of you. I have gleened numerous lessons, just reading
all the great posts you guys contribute. Thanks.


--
Casey


------------------------------------------------------------------------
Casey's Profile: http://www.excelforum.com/member.php...fo&userid=4545
View this thread: http://www.excelforum.com/showthread...hreadid=517002

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Find last used row in Range with Data above and below.

Casey,

A few suggestions:

lastRow = Range("D19").End(xlDown).Row
If lastRow 1000 Then lastRow = 19

or

lastRow = Range("D1001").End(xlUp).Row
If lastRow 19 Then lastRow = 19

or

lastRow = 18 + Application.CountA(Range("D19:D1000"))


HTH

Tim

"Casey" wrote in
message ...

Hi,
I have a named range of cells D19:D1000 (EntryAreaProposal). There is
data above this range and below this range. I want to find the last
used row within this range and of course if I use something like:

LastRow = wks2.Cells(Rows.Count, "D").End(xlUp).Row

it hits the data below my range and give me "that" last row instead of
what I need. I know this has to be simple, but it's worn me out trying
to find something in the archives.
Help please.


--
Casey


------------------------------------------------------------------------
Casey's Profile:

http://www.excelforum.com/member.php...fo&userid=4545
View this thread: http://www.excelforum.com/showthread...hreadid=517002





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Find last used row in Range with Data above and below.


Tim,
Thank you for your reply to my post. I found a fit with the code that
Jim posted, however, I appreciate the input and between the three
replies I have some great code to work into other areas. I am amazed at
the diversity of ways the same task can be accomplished. Thanks again.


--
Casey


------------------------------------------------------------------------
Casey's Profile: http://www.excelforum.com/member.php...fo&userid=4545
View this thread: http://www.excelforum.com/showthread...hreadid=517002

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
using vlookup to find data outside a specified range Art Excel Worksheet Functions 1 March 9th 10 11:09 PM
how find max data in range in excel how findout max data like text, any word[_2_] Excel Discussion (Misc queries) 6 January 17th 09 01:55 PM
Find part data in row range? Fluke Excel Worksheet Functions 1 September 11th 06 11:31 PM
Find a Range of Data John Sutton Excel Discussion (Misc queries) 4 September 11th 06 05:42 PM
Help, how to find a range of data? jub366 Excel Worksheet Functions 3 October 11th 05 01:20 AM


All times are GMT +1. The time now is 05:11 PM.

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

About Us

"It's about Microsoft Excel"