Macro required

P

pcorcele

Can someone tell me how to build a macro to do the following.
Starting at c1 check to see if there is a zero: if it IS a zero
delete the entire line
Now drop down one line to C2 and do the same and if it NOT a zero,
jump to the next line
carry on doing that until the end of any data
Thanks
Ian M
 
C

Claus Busch

Hi Ian,

Am Tue, 1 May 2012 13:01:04 -0700 (PDT) schrieb pcorcele:
Can someone tell me how to build a macro to do the following.
Starting at c1 check to see if there is a zero: if it IS a zero
delete the entire line
Now drop down one line to C2 and do the same and if it NOT a zero,
jump to the next line
carry on doing that until the end of any data

try:

Sub DeleteRows()
Dim LRow As Long
Dim i As Long

LRow = Cells(Rows.Count, 3).End(xlUp).Row
For i = LRow To 1 Step -1
If Cells(i, 3) = 0 Then
Rows(i).Delete
End If
Next
End Sub


Regards
Claus Busch
 
P

pcorcele

Hi Ian,

Am Tue, 1 May 2012 13:01:04 -0700 (PDT) schrieb pcorcele:


try:

Sub DeleteRows()
Dim LRow As Long
Dim i As Long

LRow = Cells(Rows.Count, 3).End(xlUp).Row
For i = LRow To 1 Step -1
    If Cells(i, 3) = 0 Then
        Rows(i).Delete
    End If
Next
End Sub

Regards
Claus Busch

Thanks very much..it worked very well...actually much to well....Can
you tell me how to modify the code in order that the delete would only
take place is the VALUE is zero and not delete is the cell is BLANK
Thanks Again
 
C

Claus Busch

Hi Ian,

Am Tue, 1 May 2012 16:09:38 -0700 (PDT) schrieb pcorcele:
Thanks very much..it worked very well...actually much to well....Can
you tell me how to modify the code in order that the delete would only
take place is the VALUE is zero and not delete is the cell is BLANK

a blank cell has the value 0
Try:
Sub DeleteRows()
Dim LRow As Long
Dim i As Long

LRow = Cells(Rows.Count, 3).End(xlUp).Row
For i = LRow To 1 Step -1
If Cells(i, 3) = 0 And Len(Cells(i, 3)) = 1 Then
Rows(i).Delete
End If
Next
End Sub


Regards
Claus Busch
 
P

pcorcele

Hi Ian,

Am Tue, 1 May 2012 16:09:38 -0700 (PDT) schrieb pcorcele:


a blank cell has the value 0
Try:
Sub DeleteRows()
Dim LRow As Long
Dim i As Long

LRow = Cells(Rows.Count, 3).End(xlUp).Row
For i = LRow To 1 Step -1
    If Cells(i, 3) = 0 And Len(Cells(i, 3)) = 1 Then
        Rows(i).Delete
    End If
Next
End Sub

Regards
Claus Busch

P E R F E C T
Thanks
Ian M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top