Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Getting wrong last cell when using usedrange in macro in Excel


I've been told that using ActiveSheet.UsedRange will reset the special cell
LastCell after deleting from a sheet, but Excel says the last cell is at Y102
when it should be Y10. There is nothing on row 102 at all. What's happening?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Getting wrong last cell when using usedrange in macro in Excel


This happens when the cells are formatted, although there is no data excel
thinks there is. To avoid this issue, you may want to delete all cells below
Y10 using the Ctrl - short cut is the fastest way.
Alternatively, you could use this:
iLastrow= Range("Y65536").end(xlup).Row

--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"JeffL" wrote:

I've been told that using ActiveSheet.UsedRange will reset the special cell
LastCell after deleting from a sheet, but Excel says the last cell is at Y102
when it should be Y10. There is nothing on row 102 at all. What's happening?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Getting wrong last cell when using usedrange in macro in Excel


OR...(for 2007 & 2003) where you have more number of rows

ActiveSheet.Cells(Rows.Count, "Y").End(xlUp).Row

If this post helps click Yes
---------------
Jacob Skaria


"Michael Arch" wrote:

This happens when the cells are formatted, although there is no data excel
thinks there is. To avoid this issue, you may want to delete all cells below
Y10 using the Ctrl - short cut is the fastest way.
Alternatively, you could use this:
iLastrow= Range("Y65536").end(xlup).Row

--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"JeffL" wrote:

I've been told that using ActiveSheet.UsedRange will reset the special cell
LastCell after deleting from a sheet, but Excel says the last cell is at Y102
when it should be Y10. There is nothing on row 102 at all. What's happening?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Getting wrong last cell when using usedrange in macro in Excel


The cells don't need to be formatted for Excel to treat them as used.

If the cells were cleared using "clear contents" Excel still thinks they are
used.


Gord Dibben MS Excel MVP

On Tue, 23 Jun 2009 08:12:02 -0700, Michael Arch
wrote:

This happens when the cells are formatted, although there is no data excel
thinks there is. To avoid this issue, you may want to delete all cells below
Y10 using the Ctrl - short cut is the fastest way.
Alternatively, you could use this:
iLastrow= Range("Y65536").end(xlup).Row


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Getting wrong last cell when using usedrange in macro in Excel


See also
http://www.rondebruin.nl/last.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Michael Arch" wrote in message ...
This happens when the cells are formatted, although there is no data excel
thinks there is. To avoid this issue, you may want to delete all cells below
Y10 using the Ctrl - short cut is the fastest way.
Alternatively, you could use this:
iLastrow= Range("Y65536").end(xlup).Row

--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"JeffL" wrote:

I've been told that using ActiveSheet.UsedRange will reset the special cell
LastCell after deleting from a sheet, but Excel says the last cell is at Y102
when it should be Y10. There is nothing on row 102 at all. What's happening?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Getting wrong last cell when using usedrange in macro in Excel


i think it gets reset when the workbook is saved then re-opened.
I never use it becaus eits not a safe way to determine the last row used.
use

1)
ActiveSheet.Cells(Rows.Count, "Y").End(xlUp).Row

or
2) more specific
..range("A1").End(xlDown)



"JeffL" wrote in message
...
I've been told that using ActiveSheet.UsedRange will reset the special
cell
LastCell after deleting from a sheet, but Excel says the last cell is at
Y102
when it should be Y10. There is nothing on row 102 at all. What's
happening?


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
Excel 2003 has wrong timing using the worksheet_change macro Jan Excel Worksheet Functions 0 January 14th 06 06:30 AM
cell to cell multiplications wrong in Excel (28.22 x 27=761.90) rob Excel Discussion (Misc queries) 1 September 20th 05 10:29 PM
Wrong result returned by UsedRange.Rows.Count j[_4_] Excel Programming 3 June 20th 05 09:03 PM
Macro selecting wrong cell range Josh[_10_] Excel Programming 1 June 23rd 04 06:48 PM
Excel VBA - UsedRange problem cata_and Excel Programming 6 June 4th 04 11:56 AM


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