![]() |
deleting "0" rows
Hello,
I have this code and it works perfectly for me (see code below). I want to simplify it so it dosent ask me for which column to delete "0" from. This column is always J in my worksheet. Can't figure it out though, whats the right code? Thanks... Sub deletezeros() colabel = InputBox("column label to delete zeros (ex. A, B, C...)") lrow = Cells(Rows.Count, colabel).End(xlUp).Row For i = lrow To 1 Step -1 If Cells(i, colabel) = 0 Then Rows(i).Delete Next i End Sub |
deleting "0" rows
Sub deletezeros()
colabel = 10 lrow = Cells(Rows.Count, colabel).End(xlUp).Row For i = lrow To 1 Step -1 If Cells(i, colabel) = 0 Then Rows(i).Delete Next i End Sub -- Regards, Tom Ogilvy "steven" wrote: Hello, I have this code and it works perfectly for me (see code below). I want to simplify it so it dosent ask me for which column to delete "0" from. This column is always J in my worksheet. Can't figure it out though, whats the right code? Thanks... Sub deletezeros() colabel = InputBox("column label to delete zeros (ex. A, B, C...)") lrow = Cells(Rows.Count, colabel).End(xlUp).Row For i = lrow To 1 Step -1 If Cells(i, colabel) = 0 Then Rows(i).Delete Next i End Sub |
deleting "0" rows
change
colabel = InputBox("column label to delete zeros (ex. A, B, C...)") to colabel = worksheet.columns("j") (not sure if syntax is right.............untested). susan On Feb 20, 11:29 am, steven wrote: Hello, I have this code and it works perfectly for me (see code below). I want to simplify it so it dosent ask me for which column to delete "0" from. This column is always J in my worksheet. Can't figure it out though, whats the right code? Thanks... Sub deletezeros() colabel = InputBox("column label to delete zeros (ex. A, B, C...)") lrow = Cells(Rows.Count, colabel).End(xlUp).Row For i = lrow To 1 Step -1 If Cells(i, colabel) = 0 Then Rows(i).Delete Next i End Sub |
deleting "0" rows
Sub deletezeros()
lrow = Cells(Rows.Count, "J").End(xlUp).Row For i = lrow To 1 Step -1 If Cells(i, "J").Value = 0 Then Rows(i).Delete Next i End Sub -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "steven" wrote in message ... Hello, I have this code and it works perfectly for me (see code below). I want to simplify it so it dosent ask me for which column to delete "0" from. This column is always J in my worksheet. Can't figure it out though, whats the right code? Thanks... Sub deletezeros() colabel = InputBox("column label to delete zeros (ex. A, B, C...)") lrow = Cells(Rows.Count, colabel).End(xlUp).Row For i = lrow To 1 Step -1 If Cells(i, colabel) = 0 Then Rows(i).Delete Next i End Sub |
All times are GMT +1. The time now is 09:55 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com