ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Macro Creating (https://www.excelbanter.com/new-users-excel/48180-macro-creating.html)

Duster142

Macro Creating
 

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


Gary''s Student

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



Duster142


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


--
Duster142
------------------------------------------------------------------------
Duster142's Profile: http://www.excelforum.com/member.php...o&userid=27738
View this thread: http://www.excelforum.com/showthread...hreadid=472470



All times are GMT +1. The time now is 03:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com