LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default SpecialCells(xlLastCell) selects old data

I'm using the following code to select a all the data on a sheet and
assign it a named range

Sub SetData()

Worksheets("Data").Activate

'Select last cell in data range, give is a local name "Data"
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select

Selection.Name = "Data"

End Sub

I noticed that if I reduced the size of the data range and run the code
the updated range selection is not the new smaller range, but the old,
larger range. Its as if SpecialCells(xlLastCell) looks for the last
cell ever used, not necessarily the last cell in the range.

Is there a more appropriate method to use than SpecialCellc?

or

Is there a to scrub the unused cells so that SpecialCells(xlLastCell)
doesn't recognize them?

Thanks
Robert

 
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
Fully Qualifying - ActiveCell.SpecialCells(xlLastCell)).Select tmort[_14_] Excel Programming 3 July 26th 06 08:31 PM
specialcells(xlLastCell) and method global range error [email protected] Excel Programming 0 July 25th 06 09:51 PM
.Cells.SpecialCells(xlLastCell) Simon Shaw Excel Programming 8 May 5th 05 11:46 PM
SpecialCells(xlLastCell) José Ignacio Bella Excel Programming 12 January 9th 05 07:20 PM
.SpecialCells(xlLastCell).Select jim c. Excel Programming 3 October 3rd 03 04:02 PM


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

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"