Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 52
Default Deleting a row - followup question

I was asking earlier about trying to delete a row on one sheet, that is
referenced to another cell on a summary sheet.

Jim T. said it causes the reference to become invalid, so the cell on the
summary sheet displays #REF!

I'm asking now about a macro that would automatically delete whatever row is
now invalid. How would I state that no matter which cell/row is now #REF!,
to delete that row. In other words, if a cell is #REF!, delete that row.

Thanks again.


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Deleting a row - followup question

Start from the bottom row and work your way up.

Dim iRow as long
with worksheets("Somesheethere")
for irow = .cells(.rows.count,"A").end(xlup).row to 1 step -1
if lcase(.cells(irow,"A").text) = lcase("#ref!") then
.rows(irow).delete
end if
next irow
end with

I used column A to determine the last row and to look for the reference error.



carrera wrote:

I was asking earlier about trying to delete a row on one sheet, that is
referenced to another cell on a summary sheet.

Jim T. said it causes the reference to become invalid, so the cell on the
summary sheet displays #REF!

I'm asking now about a macro that would automatically delete whatever row is
now invalid. How would I state that no matter which cell/row is now #REF!,
to delete that row. In other words, if a cell is #REF!, delete that row.

Thanks again.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 52
Default Deleting a row - followup question

I already have a macro in place to print the sheet out with all the rows
where there is data in a particular cell in the row.

Can I just take this macro starting with Dim iRow....and paste it to the end
of the print macro? I mean before the "end sub" line.

Also, what do you mean "start from the bottom and work your way up"? you
mean I have to do this to every row?!!!?


Boy, I know just enough to be dangerous.

"Dave Peterson" wrote:

Start from the bottom row and work your way up.

Dim iRow as long
with worksheets("Somesheethere")
for irow = .cells(.rows.count,"A").end(xlup).row to 1 step -1
if lcase(.cells(irow,"A").text) = lcase("#ref!") then
.rows(irow).delete
end if
next irow
end with

I used column A to determine the last row and to look for the reference error.



carrera wrote:

I was asking earlier about trying to delete a row on one sheet, that is
referenced to another cell on a summary sheet.

Jim T. said it causes the reference to become invalid, so the cell on the
summary sheet displays #REF!

I'm asking now about a macro that would automatically delete whatever row is
now invalid. How would I state that no matter which cell/row is now #REF!,
to delete that row. In other words, if a cell is #REF!, delete that row.

Thanks again.


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Deleting a row - followup question

I'd move the Dim statement to the top of the code--that's where I put all my
declarations.

Looping from the bottom up is one way to inspect every cell to see what they
contain.

If you can get rid of all the errors (ref, value, div/0, ...), you could use
something like:

on error resume next
worksheets("somesheetnamehere").range("a1").entire column _
.cells.specialcells(xlCellTypeFormulas, xlerrors).entirerow.delete
on error goto 0

It's looking for any error in any formula in any cell in column A.



carrera wrote:

I already have a macro in place to print the sheet out with all the rows
where there is data in a particular cell in the row.

Can I just take this macro starting with Dim iRow....and paste it to the end
of the print macro? I mean before the "end sub" line.

Also, what do you mean "start from the bottom and work your way up"? you
mean I have to do this to every row?!!!?

Boy, I know just enough to be dangerous.

"Dave Peterson" wrote:

Start from the bottom row and work your way up.

Dim iRow as long
with worksheets("Somesheethere")
for irow = .cells(.rows.count,"A").end(xlup).row to 1 step -1
if lcase(.cells(irow,"A").text) = lcase("#ref!") then
.rows(irow).delete
end if
next irow
end with

I used column A to determine the last row and to look for the reference error.



carrera wrote:

I was asking earlier about trying to delete a row on one sheet, that is
referenced to another cell on a summary sheet.

Jim T. said it causes the reference to become invalid, so the cell on the
summary sheet displays #REF!

I'm asking now about a macro that would automatically delete whatever row is
now invalid. How would I state that no matter which cell/row is now #REF!,
to delete that row. In other words, if a cell is #REF!, delete that row.

Thanks again.


--

Dave Peterson


--

Dave Peterson
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
Followup: Folder listing [email protected] Excel Discussion (Misc queries) 1 February 23rd 07 02:23 AM
Followup:Add vertical line at intersection of 2 curves (Ping AndyPope) LeAnne Charts and Charting in Excel 2 May 30th 06 08:28 PM
Question about deleting rows and formulas [email protected] Excel Discussion (Misc queries) 14 February 11th 06 11:53 PM
countif followup Lee Harris Excel Worksheet Functions 3 November 16th 05 06:13 AM
Bob Phillips followup question on text macro kayabob Excel Discussion (Misc queries) 2 June 27th 05 05:13 PM


All times are GMT +1. The time now is 11:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"