Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default reset the data range...

I did a copy of a sheet that has about 20,000 rows to another sheet (
the paste is only values). I then do a sort to bring only the rows
that have data in the firs column to tha top. I then search for a cell
in the first column that has "Grand Total" as a value. I set this as my
starting row and use the last row (Derived using SpecialCells....) to
set a range and I delete it .

All this works great.. The only problem is that excel still thinks that
the last data row is the original last data row even thou ther is
nothing there.. what am I doing wrong?????

this is the code..

Dim ir As Long, mrows As Long, lastcell As Range, FoundCell As Range

Sheets("Projects").Select
Cells.Copy
Sheets.Add
ActiveSheet.Name = "Temp"
Selection.PasteSpecial Paste:=xlPasteValues

Set lastcell = Cells.SpecialCells(xlLastCell)
mrows = lastcell.Row

Range("A3:P" & mrows).Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("A3"), Order1:=xlAscending
Set FoundCell = Cells.Find(What:="Grand Total")
Range(FoundCell.Address & ":P" & mrows).Delete

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default reset the data range...

Hi Chris,

See Debra Dalgleish's page on resetting the used range at:

http://www.contextures.com/xlfaqApp.html#Unused


---
Regards,
Norman



"Chris Salcedo" wrote in message
oups.com...
I did a copy of a sheet that has about 20,000 rows to another sheet (
the paste is only values). I then do a sort to bring only the rows
that have data in the firs column to tha top. I then search for a cell
in the first column that has "Grand Total" as a value. I set this as my
starting row and use the last row (Derived using SpecialCells....) to
set a range and I delete it .

All this works great.. The only problem is that excel still thinks that
the last data row is the original last data row even thou ther is
nothing there.. what am I doing wrong?????

this is the code..

Dim ir As Long, mrows As Long, lastcell As Range, FoundCell As Range

Sheets("Projects").Select
Cells.Copy
Sheets.Add
ActiveSheet.Name = "Temp"
Selection.PasteSpecial Paste:=xlPasteValues

Set lastcell = Cells.SpecialCells(xlLastCell)
mrows = lastcell.Row

Range("A3:P" & mrows).Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("A3"), Order1:=xlAscending
Set FoundCell = Cells.Find(What:="Grand Total")
Range(FoundCell.Address & ":P" & mrows).Delete

End Sub



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
reset a range of cells to zero Jen Excel Discussion (Misc queries) 1 August 4th 09 10:29 PM
reset the range of FOR loop Farooq Sheri Excel Discussion (Misc queries) 1 April 7th 09 08:05 PM
How do you reset vertical scoll bar to range of data? AWM1957 Excel Discussion (Misc queries) 1 October 16th 07 08:11 PM
x y scatter chart series ranges reset to x(range) = y(range) Brakerm19 Charts and Charting in Excel 4 September 26th 06 11:13 PM
how do you set or reset the print range for several sheets at a ti Mestrella31 Excel Programming 2 January 10th 05 05:28 PM


All times are GMT +1. The time now is 08:30 AM.

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"