Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default lastrow question

have text in rows 61 and 62 and i want the lastrow before that (45). i know
i can start at the top and go down, but i want to do this.

anyway

sLastRow = .Cells(Rows.Count, "B").End(xlUp).Row ' gives me 62
sLastRow = .Cells(Rows.Count, "B").End(xlUp)(3).Row 'gives me 64
sLastRow = .Cells(Rows.Count, "B").End(xlUp).End(xlUp).End(xlUp).Row
'gives me 45, which is what i want

why doesn't the 2nd one work?
--


Gary


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default lastrow question

Hi Gary,

sLastRow = .Cells(Rows.Count, "B").End(xlUp)(3).Row 'gives me 64


The expression is eqiuvalent to:

sLastRow = .Cells(Rows.Count, "B").End(xlUp).Cells.Item(3).Row

or

sLastRow = .Cells(Rows.Count, "B").End(xlUp).Offset(2).Row



---
Regards,
Norman



"GKeramidas" wrote in message
...
have text in rows 61 and 62 and i want the lastrow before that (45). i
know i can start at the top and go down, but i want to do this.

anyway

sLastRow = .Cells(Rows.Count, "B").End(xlUp).Row ' gives me 62
sLastRow = .Cells(Rows.Count, "B").End(xlUp)(3).Row 'gives me 64
sLastRow = .Cells(Rows.Count, "B").End(xlUp).End(xlUp).End(xlUp).Row
'gives me 45, which is what i want

why doesn't the 2nd one work?
--


Gary




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default lastrow question

thanks for the explanation norman. so, is the way i have it return 45 the
best way, then?

--


Gary


"Norman Jones" wrote in message
...
Hi Gary,

sLastRow = .Cells(Rows.Count, "B").End(xlUp)(3).Row 'gives me 64


The expression is eqiuvalent to:

sLastRow = .Cells(Rows.Count, "B").End(xlUp).Cells.Item(3).Row

or

sLastRow = .Cells(Rows.Count, "B").End(xlUp).Offset(2).Row



---
Regards,
Norman



"GKeramidas" wrote in message
...
have text in rows 61 and 62 and i want the lastrow before that (45). i
know i can start at the top and go down, but i want to do this.

anyway

sLastRow = .Cells(Rows.Count, "B").End(xlUp).Row ' gives me 62
sLastRow = .Cells(Rows.Count, "B").End(xlUp)(3).Row 'gives me 64
sLastRow = .Cells(Rows.Count, "B").End(xlUp).End(xlUp).End(xlUp).Row
'gives me 45, which is what i want

why doesn't the 2nd one work?
--


Gary





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default lastrow question

Hi Gary,

thanks for the explanation norman. so, is the way i have it return 45 the
best way, then?


Subject to your data configuration, your method is fine!


---
Regards,
Norman


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default lastrow question

ok, thanks again

--


Gary


"Norman Jones" wrote in message
...
Hi Gary,

thanks for the explanation norman. so, is the way i have it return 45 the
best way, then?


Subject to your data configuration, your method is fine!


---
Regards,
Norman



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
Lastrow Bishop Excel Worksheet Functions 2 May 13th 09 05:22 PM
Lastrow Mr. Damon[_2_] Excel Worksheet Functions 3 July 30th 08 04:12 PM
LastRow of Data phmckeever Excel Worksheet Functions 1 December 1st 06 09:04 PM
Go to lastrow using other column's lastrow stakar[_14_] Excel Programming 5 April 16th 04 03:42 PM
Help with LastRow JStone0218 Excel Programming 4 December 4th 03 04:50 PM


All times are GMT +1. The time now is 05:25 AM.

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"