Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default find last record in macro and delete all after

How do I design a macro to find the last record in a report and delete each
row after. Keeping in mind that the cell reference can change to where the
last record is found??? Help please!!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default find last record in macro and delete all after

If it is the last record, then what is being deleted. If there is something
different from records, in the sheet, then how do you distinguish a record
from other data.

if the address of the last record is known (assume it is A132

lastRecordAddress = "A123"

Range(lastRecordAddress, "A65535").Offset(1,0).EntireRow.Delete

--
Regards,
Tom Ogilvy

"Sherife" wrote in message
...
How do I design a macro to find the last record in a report and delete
each
row after. Keeping in mind that the cell reference can change to where
the
last record is found??? Help please!!!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default find last record in macro and delete all after

Thanks for being so quick! I have to add information to an invoice so with
each invoice the last record changes and that's why I need it to find the
last record and then delete the added information after that. I add the
extra information to several cells in a column so that if more records come
in month to month that information flows down the page far enough to match
each additional record

"Tom Ogilvy" wrote:

If it is the last record, then what is being deleted. If there is something
different from records, in the sheet, then how do you distinguish a record
from other data.

if the address of the last record is known (assume it is A132

lastRecordAddress = "A123"

Range(lastRecordAddress, "A65535").Offset(1,0).EntireRow.Delete

--
Regards,
Tom Ogilvy

"Sherife" wrote in message
...
How do I design a macro to find the last record in a report and delete
each
row after. Keeping in mind that the cell reference can change to where
the
last record is found??? Help please!!!




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default find last record in macro and delete all after

assume the data starts in F3

Sub Cleanup()
Dim rng as range
set rng = Range("F3")
if isemtpy(rng) then exit sub
if not isblank(Range("F3").Offset(1,0)) then
set rng = rng.End(xldown))
rng.offset(1,0).Resize(100,10).Clearcontents
end if
end sub

Since your description was extremely general, adjust the above to suit your
specific situation

--
Regards,
Tom Ogilvy


"Sherife" wrote in message
...
Thanks for being so quick! I have to add information to an invoice so
with
each invoice the last record changes and that's why I need it to find the
last record and then delete the added information after that. I add the
extra information to several cells in a column so that if more records
come
in month to month that information flows down the page far enough to match
each additional record

"Tom Ogilvy" wrote:

If it is the last record, then what is being deleted. If there is
something
different from records, in the sheet, then how do you distinguish a
record
from other data.

if the address of the last record is known (assume it is A132

lastRecordAddress = "A123"

Range(lastRecordAddress, "A65535").Offset(1,0).EntireRow.Delete

--
Regards,
Tom Ogilvy

"Sherife" wrote in message
...
How do I design a macro to find the last record in a report and delete
each
row after. Keeping in mind that the cell reference can change to where
the
last record is found??? Help please!!!






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
Macro to find and record Unique values? Arlen Excel Discussion (Misc queries) 7 July 18th 08 01:07 PM
find last record in macro and delete all after Sherife Excel Discussion (Misc queries) 3 September 18th 06 03:51 AM
how to get a macro to record F2, Home, Delete keystrokes jenonstx Excel Programming 1 July 22nd 05 03:25 AM
Macro to delete record and validation problem Bob[_40_] Excel Programming 5 December 9th 03 01:35 PM
delete record using Macro in excel spreed sheet Lillian[_3_] Excel Programming 47 December 3rd 03 04:06 PM


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