Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Last cell determined different in XP/2003 as in 2000

Hello FellowNewsgroupReaders,

I adapted the 'last cell' macro from David McRitchie OR Chip Pearson (sorry
guys, I couldn't find it back eather).

This macro looks for the actual last filled cell in a sheet. It works
wonderful! Until now, that is.

In a sheet I created a last row that will not be used, just for a reference
as the last row. All other items are added before this row. I filled it with
the text "Last hidden row" and it is hidden. The sheet is protected with a
password. The 'stdLastCell' macro always tells me what row that is.
Now in Excel 2000 this all works fine. In Excel XP and 2003 however the las
row reported is NOT the hidden last row but the visible last row. If I set
off the protection of the sheet it will work fine.

Here's my macro's:

*************
Sub FindLast

Dim Test
Test = stdLastCell("Sheet1").Row

End sub

Function stdLastCell(strSheetname) As Range

' Returns the real last cell

Dim intLastRow As Integer
Dim intLastCol As Integer
Dim wsSearch As Worksheet
Set wsSearch = Sheets(Worksheets(strSheetname).Index)
' Error-handling
On Error Resume Next
With wsSearch
' find the real last row
intLastRow = .Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row
' find the real liast column
intLastCol = .Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column
End With
'
Set stdLastCell = wsSearch.Cells(intLastRow, intLastCol)
End Function
*********

Any ideas why this is a difference?

Rob





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
Insert # of Rows determined by cell Justin H Excel Discussion (Misc queries) 13 December 6th 07 09:25 PM
Excel 2000 and 2003 stuck in cell Matthew Lightbourn Setting up and Configuration of Excel 1 October 3rd 06 02:06 PM
Getting a value from a cell that is determined by a formula carl43m Excel Discussion (Misc queries) 3 August 14th 06 06:31 PM
Cell Protection over Excel 2000 and 2003 Achez Excel Discussion (Misc queries) 3 June 6th 06 07:50 PM
CELL PROTECTED IN 2000, UNPROTECTED IN 2003 Carole O Excel Worksheet Functions 0 January 20th 05 07:17 PM


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