Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default .Cells.SpecialCells(xlLastCell)

If you know that only column A was used, you could do something like:

dim LastCell as range
with activesheet
set lastcell = .cells(.rows.count,"A").end(xlup)
end with



CyndyG wrote:

How could I use this code when the last cell of the data contains character
127(the end of file character) and all the data is in column A,there is only
1 worksheet.

"indiana1138" wrote:

Hello Simon,

Other folks have found that Excel does not work as advertised in this
respect. Try this code for something that might work:

Function LastCell(Optional ws As Worksheet) As Range
If ws Is Nothing Then Set ws = ActiveSheet
Set Rng = ws.Cells
Set LastCell = Rng(1)
On Error Resume Next
Set LastCell = Intersect( _
Rng.Find("*", Rng(1), xlValues, xlWhole, xlByRows, _
xlPrevious).EntireRow, _
Rng.Find("*", Rng(1), xlValues, xlWhole, xlByColumns, _
xlPrevious).EntireColumn)
End Function

Hope this helps,

Bob



--

Dave Peterson
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
SpecialCells(xlLastCell) José Ignacio Bella Excel Programming 12 January 9th 05 07:20 PM
How select/define cells with FIND method (maybe together with SpecialCells) Marie J-son[_5_] Excel Programming 2 December 14th 04 03:49 PM
xlLastCell question Rich[_16_] Excel Programming 1 December 1st 03 08:35 AM
.SpecialCells(xlLastCell).Select jim c. Excel Programming 3 October 3rd 03 04:02 PM
XP VBA: Range("A2", ActiveCell.SpecialCells(xlLastCell)).Select wessman Excel Programming 2 July 23rd 03 06:33 PM


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