Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Deleting rows when cell has "#DIV/0!" error

Hi,

I'm currently using this code to delete rows with balnk cells. However, i
have changes the formatting of my sheet and the cells are no longer blank
they have the "#DIV/0!" error. How can I delete the entire row when the cell
in column D has that value?

Sub DeleteRowsIfDIsBlank()

With payrollsht

Dim rg As Range, rgBlank As Range

Set rg = Cells.Range("D:D")

On Error Resume Next

Set rgBlank = rg.SpecialCells(xlCellTypeBlanks)

On Error GoTo 0

If rgBlank Is Nothing Then

Else

rgBlank.EntireRow.Delete

End If

End With

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Deleting rows when cell has "#DIV/0!" error

Hi matt,

In Excel 2003 I creates this:

Sub DeleteRowsIfDIsError()

Dim i As Integer
With ActiveSheet
' start with last used row
For i = Cells(65536, 4).End(xlUp).Row _
To 1 Step -1
If IsError(Cells(i, 4).Value) Then
Rows(i).EntireRow.Delete
End If
Next
End With
End Sub

HTH,

Wouter
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Deleting rows when cell has "#DIV/0!" error

Hi Mattg,

If #DIV/0! is the only error in Column D you could try a loop with

Set rgError = rg.SpecialCells(xlCellTypeFormulas, xlErrors)

or something like that (bearing in mind the limitations of Specialcells)

HTH

"mattg" wrote in message
...
Hi,

I'm currently using this code to delete rows with balnk cells. However, i
have changes the formatting of my sheet and the cells are no longer blank
they have the "#DIV/0!" error. How can I delete the entire row when the

cell
in column D has that value?

Sub DeleteRowsIfDIsBlank()

With payrollsht

Dim rg As Range, rgBlank As Range

Set rg = Cells.Range("D:D")

On Error Resume Next

Set rgBlank = rg.SpecialCells(xlCellTypeBlanks)

On Error GoTo 0

If rgBlank Is Nothing Then

Else

rgBlank.EntireRow.Delete

End If

End With

End Sub



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
Deleting rows when cell text reads "Research" iashorty Excel Programming 2 November 7th 08 07:07 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
Look for cell containing "Initial" then if the next cell after equals "Final" then delete both rows. [email protected][_2_] Excel Programming 3 September 28th 07 01:45 PM
Suppress Error Dialog: "Data may exist in the sheet(s) selected for deleting...." (PeteCresswell) Excel Programming 2 May 1st 07 09:25 PM
Deleting groups of continuous rows where col K = "x" Max Excel Programming 6 February 18th 06 11:21 PM


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