View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Adding/removing rows in Excel

Assume column A can be used to find the number of rows

set rng = Range(cells(1,1),cells(rows.count,1).End(xlup))

for each cell in rng

If you have a data table/database construct

set rng = range("a1").CurrentRegion

in either case

Dim lastrow as Long
lastrow = rng.rows(rng.row.count).row

for i = lastrow to 1 step -1
if cells(lastrow,1).Value = 0 then
cells(lastrow,1).EntireRow.Delete
end if
Next

as an example.
--
Regards,
Tom Ogilvy



"Don" wrote in message
...
Is there an easy way of making code change automatically
to make allowance for adding or removing rows in a
spreadsheet, without manually changing the code ?