Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
EJ EJ is offline
external usenet poster
 
Posts: 20
Default Delete 0 - Column D and Column F

Is there a macro that will check each row in Column D and Column F for "0",
so that when both columns in the same row have "0" and only when both columns
in the same row have "0" the contents "0" in that row of Column D and F will
be deleted simultaneously? I know the code below will delete the contents
but only if its in row D.


Sub DeletezerowhenincolumnDandColumnF()
Dim myLastRow As Long
Dim r As Long
Dim c As Range
myLastRow = ActiveSheet.Cells(10000, 4).End(xlUp).Row
For r = myLastRow To 1 Step -1
Set c = ActiveSheet.Range("d" & r)
If c.Value = "0" Then
c.ClearContents
End If
Next r
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Delete 0 - Column D and Column F

hi
i modified your code. works in xl03
Sub DeletezerowhenincolumnDandColumnF()
Dim myLastRow As Long
Dim r As Long
Dim c As Range
myLastRow = ActiveSheet.Cells(10000, 4).End(xlUp).Row
For r = myLastRow To 1 Step -1
Set c = ActiveSheet.Range("d" & r)
If c.Value = 0 And c.Offset(0, 2) = 0 Then
c.ClearContents
c.Offset(0, 2).ClearContents
End If
Next r
End Sub

regards
FSt1
"EJ" wrote:

Is there a macro that will check each row in Column D and Column F for "0",
so that when both columns in the same row have "0" and only when both columns
in the same row have "0" the contents "0" in that row of Column D and F will
be deleted simultaneously? I know the code below will delete the contents
but only if its in row D.


Sub DeletezerowhenincolumnDandColumnF()
Dim myLastRow As Long
Dim r As Long
Dim c As Range
myLastRow = ActiveSheet.Cells(10000, 4).End(xlUp).Row
For r = myLastRow To 1 Step -1
Set c = ActiveSheet.Range("d" & r)
If c.Value = "0" Then
c.ClearContents
End If
Next r
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
EJ EJ is offline
external usenet poster
 
Posts: 20
Default Delete 0 - Column D and Column F

This works fantastically. Thank you.

"FSt1" wrote:

hi
i modified your code. works in xl03
Sub DeletezerowhenincolumnDandColumnF()
Dim myLastRow As Long
Dim r As Long
Dim c As Range
myLastRow = ActiveSheet.Cells(10000, 4).End(xlUp).Row
For r = myLastRow To 1 Step -1
Set c = ActiveSheet.Range("d" & r)
If c.Value = 0 And c.Offset(0, 2) = 0 Then
c.ClearContents
c.Offset(0, 2).ClearContents
End If
Next r
End Sub

regards
FSt1
"EJ" wrote:

Is there a macro that will check each row in Column D and Column F for "0",
so that when both columns in the same row have "0" and only when both columns
in the same row have "0" the contents "0" in that row of Column D and F will
be deleted simultaneously? I know the code below will delete the contents
but only if its in row D.


Sub DeletezerowhenincolumnDandColumnF()
Dim myLastRow As Long
Dim r As Long
Dim c As Range
myLastRow = ActiveSheet.Cells(10000, 4).End(xlUp).Row
For r = myLastRow To 1 Step -1
Set c = ActiveSheet.Range("d" & r)
If c.Value = "0" Then
c.ClearContents
End If
Next r
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Delete 0 - Column D and Column F

glad to help. thanks for the feedback.
regards
FSt1

"EJ" wrote:

This works fantastically. Thank you.

"FSt1" wrote:

hi
i modified your code. works in xl03
Sub DeletezerowhenincolumnDandColumnF()
Dim myLastRow As Long
Dim r As Long
Dim c As Range
myLastRow = ActiveSheet.Cells(10000, 4).End(xlUp).Row
For r = myLastRow To 1 Step -1
Set c = ActiveSheet.Range("d" & r)
If c.Value = 0 And c.Offset(0, 2) = 0 Then
c.ClearContents
c.Offset(0, 2).ClearContents
End If
Next r
End Sub

regards
FSt1
"EJ" wrote:

Is there a macro that will check each row in Column D and Column F for "0",
so that when both columns in the same row have "0" and only when both columns
in the same row have "0" the contents "0" in that row of Column D and F will
be deleted simultaneously? I know the code below will delete the contents
but only if its in row D.


Sub DeletezerowhenincolumnDandColumnF()
Dim myLastRow As Long
Dim r As Long
Dim c As Range
myLastRow = ActiveSheet.Cells(10000, 4).End(xlUp).Row
For r = myLastRow To 1 Step -1
Set c = ActiveSheet.Range("d" & r)
If c.Value = "0" Then
c.ClearContents
End If
Next r
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
Copy column header to next column, delete & delete every nth colum genehunter New Users to Excel 1 June 2nd 09 03:57 PM
Search from bottom of column up column and delete to top Jools Excel Programming 1 January 23rd 08 02:05 AM
Delete Rows if any cell in Column H is blank but do not Delete Fir manfareed Excel Programming 4 September 28th 07 05:20 PM
Find Column heading and then Delete entire column Kobayashi[_58_] Excel Programming 4 October 17th 05 09:09 PM
Delete All Rows That Column A value is not in Column A of Sheet2 [email protected] Excel Programming 2 September 3rd 04 09:13 PM


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