Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Another "last row" question

An entity in my office makes a worksheet with tasks on it.

Sometimes there are 200.
Sometimes there are 300.
Usually it is somewhere in between, but it can be more or less.

I am writing a macro that does a variety of transformations to the data in
this sheet.

For simplicity, I have a lot of the transformations fill down to row 350 or
so. It's a nice round number and we'll almost never have more than 350 items
in the sheet.

Using the "search" feature on this forum, I've found how to identify the
last row with data. For the sake of my example, let's say 285 is the last row
with data.

What I *want* to do is select rows 286-350 and delete them to clean up the
bottom of the sheet. I've found a lot of code in this newsgroup for filling
in data down TO the last row, but nothing regarding selecting a range BELOW
the last row.

Example, again; something like this:

lastrange = Range("K500:A" & lastrow + 1)
Range(lastrange).Activate
ActiveCell.Delete

(I realize that exact code does nothing.) Anyway, the idea there is maybe to
select all the cells from A(lastrow) to K500 and delete them.

Thoughts are most welcome!

Thanks

Jim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Another "last row" question

firstrow = Range("A1").End(xlDown).Row +1

with range(cells(firstrow,"A"),cells(350,"A") )
..clearcontents
end with


"JaimeZX" wrote:

An entity in my office makes a worksheet with tasks on it.

Sometimes there are 200.
Sometimes there are 300.
Usually it is somewhere in between, but it can be more or less.

I am writing a macro that does a variety of transformations to the data in
this sheet.

For simplicity, I have a lot of the transformations fill down to row 350 or
so. It's a nice round number and we'll almost never have more than 350 items
in the sheet.

Using the "search" feature on this forum, I've found how to identify the
last row with data. For the sake of my example, let's say 285 is the last row
with data.

What I *want* to do is select rows 286-350 and delete them to clean up the
bottom of the sheet. I've found a lot of code in this newsgroup for filling
in data down TO the last row, but nothing regarding selecting a range BELOW
the last row.

Example, again; something like this:

lastrange = Range("K500:A" & lastrow + 1)
Range(lastrange).Activate
ActiveCell.Delete

(I realize that exact code does nothing.) Anyway, the idea there is maybe to
select all the cells from A(lastrow) to K500 and delete them.

Thoughts are most welcome!

Thanks

Jim

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Another "last row" question

Wow! That's a quick reply!

Thanks very much. At first I thought there was an issue with the code but
then realized I had goofed the implementation a bit.

Thanks so much, it's perfect!

Jim

"Patrick Molloy" wrote:

firstrow = Range("A1").End(xlDown).Row +1

with range(cells(firstrow,"A"),cells(350,"A") )
.clearcontents
end with


"JaimeZX" wrote:

An entity in my office makes a worksheet with tasks on it.

Sometimes there are 200.
Sometimes there are 300.
Usually it is somewhere in between, but it can be more or less.

I am writing a macro that does a variety of transformations to the data in
this sheet.

For simplicity, I have a lot of the transformations fill down to row 350 or
so. It's a nice round number and we'll almost never have more than 350 items
in the sheet.

Using the "search" feature on this forum, I've found how to identify the
last row with data. For the sake of my example, let's say 285 is the last row
with data.

What I *want* to do is select rows 286-350 and delete them to clean up the
bottom of the sheet. I've found a lot of code in this newsgroup for filling
in data down TO the last row, but nothing regarding selecting a range BELOW
the last row.

Example, again; something like this:

lastrange = Range("K500:A" & lastrow + 1)
Range(lastrange).Activate
ActiveCell.Delete

(I realize that exact code does nothing.) Anyway, the idea there is maybe to
select all the cells from A(lastrow) to K500 and delete them.

Thoughts are most welcome!

Thanks

Jim

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
Can I make a "tab name" the "chart title"? (question on this) [email protected] Charts and Charting in Excel 2 April 15th 09 06:26 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
"Disk is Full" add-on question to "Can't reset last cell" post tod [email protected] Excel Discussion (Misc queries) 0 January 22nd 07 02:32 AM
Question on determining "ROW" inside of a "For .. RANGE " loop David Schrader[_2_] Excel Programming 2 January 3rd 07 08:18 PM
Validation question - allow -500%, 0%, "=50%*50%" but forbid "A", "", " ", "-" ? tskogstrom Excel Programming 2 November 27th 06 09:50 AM


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