Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Delete Cells when error

Hi,

what am I doing wrong here? I need to delete cells D & E if there is an
error in D.

With Sheets("Table")
LrowinD = .Cells(.Rows.Count, "D").End(xlUp).Row

For iCtr = LrowinD To FrowinD Step -1
With .Cells(LrowinD, "D")
If IsError(.Value) Then
.Cells(LrowinD, "D:E").Select
Selection.Delete Shift:=xlUp
End If
End With
Next
End With

Thanks for yor help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Delete Cells when error

Karen,

Try,

Sub marine()
FrowinD = 1
With Sheets("Table")
LrowinD = .Cells(.Rows.Count, "D").End(xlUp).Row
For ictr = LrowinD To FrowinD Step -1
If IsError(Cells(ictr, 4).Value) Then
Range("D" & ictr & ":E" & ictr).Select
Selection.Delete Shift:=xlUp
End If
Next
End With
End Sub

Mike

"Karen53" wrote:

Hi,

what am I doing wrong here? I need to delete cells D & E if there is an
error in D.

With Sheets("Table")
LrowinD = .Cells(.Rows.Count, "D").End(xlUp).Row

For iCtr = LrowinD To FrowinD Step -1
With .Cells(LrowinD, "D")
If IsError(.Value) Then
.Cells(LrowinD, "D:E").Select
Selection.Delete Shift:=xlUp
End If
End With
Next
End With

Thanks for yor help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Delete Cells when error

Yea!!! Thank you Mike!

"Mike H" wrote:

Karen,

Try,

Sub marine()
FrowinD = 1
With Sheets("Table")
LrowinD = .Cells(.Rows.Count, "D").End(xlUp).Row
For ictr = LrowinD To FrowinD Step -1
If IsError(Cells(ictr, 4).Value) Then
Range("D" & ictr & ":E" & ictr).Select
Selection.Delete Shift:=xlUp
End If
Next
End With
End Sub

Mike

"Karen53" wrote:

Hi,

what am I doing wrong here? I need to delete cells D & E if there is an
error in D.

With Sheets("Table")
LrowinD = .Cells(.Rows.Count, "D").End(xlUp).Row

For iCtr = LrowinD To FrowinD Step -1
With .Cells(LrowinD, "D")
If IsError(.Value) Then
.Cells(LrowinD, "D:E").Select
Selection.Delete Shift:=xlUp
End If
End With
Next
End With

Thanks for yor help.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Delete Cells when error

Mike has provided a nice solution. However, I would recommend
removing the select line. It is good coding practice to not select
anything if not absolutely necessary.
You could replace this:
If IsError(Cells(ictr, 4).Value) Then
Range("D" & ictr & ":E" & ictr).Select
Selection.Delete Shift:=xlUp
End If

With this:
If IsError(Cells(ictr, 4).Value) Then _
Range("D" & ictr & ":E" & ictr).Delete Shift:=xlUp

Karen53 wrote:
Yea!!! Thank you Mike!

"Mike H" wrote:

Karen,

Try,

Sub marine()
FrowinD = 1
With Sheets("Table")
LrowinD = .Cells(.Rows.Count, "D").End(xlUp).Row
For ictr = LrowinD To FrowinD Step -1
If IsError(Cells(ictr, 4).Value) Then
Range("D" & ictr & ":E" & ictr).Select
Selection.Delete Shift:=xlUp
End If
Next
End With
End Sub

Mike

"Karen53" wrote:

Hi,

what am I doing wrong here? I need to delete cells D & E if there is an
error in D.

With Sheets("Table")
LrowinD = .Cells(.Rows.Count, "D").End(xlUp).Row

For iCtr = LrowinD To FrowinD Step -1
With .Cells(LrowinD, "D")
If IsError(.Value) Then
.Cells(LrowinD, "D:E").Select
Selection.Delete Shift:=xlUp
End If
End With
Next
End With

Thanks for yor help.


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
delete cells column. Delete empty cells myshak Excel Worksheet Functions 0 March 9th 09 10:59 PM
delete error/blank cells Ask MS[_2_] Excel Worksheet Functions 3 June 30th 08 01:54 PM
How to delete all the blanc cells in a worksheet and shift cells l tiramisu Excel Discussion (Misc queries) 2 December 7th 06 03:45 AM
macro to select cells containing specific text and delete all cells but these JenIT Excel Programming 3 March 27th 06 10:07 PM
Delete specific cells contents in a row with some locked cells in the same row trussman Excel Programming 2 March 1st 05 06:12 PM


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