Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Fully Qualifying - ActiveCell.SpecialCells(xlLastCell)).Select | Excel Programming | |||
specialcells(xlLastCell) and method global range error | Excel Programming | |||
.Cells.SpecialCells(xlLastCell) | Excel Programming | |||
SpecialCells(xlLastCell) | Excel Programming | |||
.SpecialCells(xlLastCell).Select | Excel Programming |