View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default adding lines of code to a macro to delete rows

Again, per my posting, I didn't say to rely on an exact row number... what I
said was to remember the row number that **your code** used when it placed
the word "Grand" into whatever cell it placed the word Grand into. Your code
does do the placing of the word Grand into a cell, right? Just so you
understand our problems in trying to answer your question... we cannot see
your code (because you didn't post it), so we have to make guesses as to
what you have and what it is you are doing with it. If you could post your
code, that would make answering your question so much easier.

--
Rick (MVP - Excel)


"childofthe1980s" wrote in
message ...
Again, per my posting, I cannot rely on an exact row number.

"Rick Rothstein" wrote:

Since the word row in Column A that the word "Grand" is in was put there
by
your code, then you already know the row number for it... just store that
**row number** in a variable at the same time you put the word "Grand"
into
its cell, then at the end of your code, you can execute this statement to
clear that row downward...

Range(RowWithGrandVariable & ":" & Rows.Count).Clear

Of course, use your actual variable's name for the example variable name
of
RowWithGrandVariable that I used above.

--
Rick (MVP - Excel)


"childofthe1980s" wrote in
message ...
Hello:

As the last step of a macro that I have written, I need all rows at the
end
of this spreadsheet to be deleted. (The rows at the end of the
spreadsheet
have bogus data, and I need to get rid of all of those rows and leave
just
rows of "real" data--long story short.)

Specifically, the row after the last row of "real" data is a cell in
column
A that simply contains the word "Grand". How do I put in code at the
end
that says "delete all rows at the end of this spreadsheet beginning
with
this
last row that contains just the word 'Grand' at the end of column A"?

At the moment, "Grand" is in cell A667. But, that is not going to be
the
case everytime that I run this macro for this data. Next time, "Grand"
could
be in cell A748, A901, A820, who knows?.......So, I cannot simply put
in
code
that says "delete all rows at the end of this spreadsheet beginning
with
the
row at cell A667".

Thanks!

childofthe1980s


.