I have tried and tried to create a MACRO in Excel that will will delete a row. I have read several other marcos but have been unable to translate them to what I want to do. Listed below a sample of the type data I am talking about. What I want to do is have the macro read the second number in the colum and everytime it read a 0 it deletes that whole line of information. This type table will have some blank row but I do not want to delete. Can anyone help. Thanks in advance. Ron
D60801 0 0 0 0 0
D78555 0 0 0 0 0
E98103 0 0 0 0 0
N04456 0 0 0 0 0
N05482 3 60 0 0 0
N95862 0 0 0 0 0
N96248 3 8.25 0 0 0
R59160 0 0 0 0 0
R67908 0 0 0 0 0
R67976 0 0 0 0 0
R68044 3 204 0 0 0
Try:
Sub Macro1()
Dim i As Long
For i = 13 To 1 Step -1
Rows(i).Select
If IsEmpty(Cells(i, 2)) Then
Else
If Cells(i, 2) = 0 Then
Selection.Delete
End If
End If
Next
End Sub
Change the 13 to reflect your actual table size.
--
Gary''s Student
"Duster142" wrote:
>
> I have tried and tried to create a MACRO in Excel that will will delete
> a row. I have read several other marcos but have been unable to
> translate them to what I want to do. Listed below a sample of the type
> data I am talking about. What I want to do is have the macro read the
> second number in the colum and everytime it read a 0 it deletes that
> whole line of information. This type table will have some blank row
> but I do not want to delete. Can anyone help. Thanks in advance. Ron
>
>
> D60801 0 0 0 0 0
> D78555 0 0 0 0 0
> E98103 0 0 0 0 0
> N04456 0 0 0 0 0
> N05482 3 60 0 0 0
> N95862 0 0 0 0 0
> N96248 3 8.25 0 0 0
>
>
> R59160 0 0 0 0 0
> R67908 0 0 0 0 0
> R67976 0 0 0 0 0
> R68044 3 204 0 0 0
>
>
> --
> Duster142
> ------------------------------------------------------------------------
> Duster142's Profile: http://www.excelforum.com/member.php...o&userid=27738
> View this thread: http://www.excelforum.com/showthread...hreadid=472470
>
>
Thank you Gary,
What I found that I had to do to the script you provided was to add " around the 0 and then it worked like a charm. You will never no how much time this little Macro is going to save myself and three others that work with me.
If Cells(i, 2) = 0 Then
If Cells(i, 2) = "0" Then
Thanks a million,
Ron
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks