![]() |
Hiding an empty row?
Hi I currently use the following code to delete the entire row if it empty in a selection. Code: -------------------- Sub del_empty_row() Rng = Selection.Rows.Count ActiveCell.Offset(0, 0).Select Application.ScreenUpdating = False For i = 1 To Rng If ActiveCell.Value = 0 Then Selection.EntireRow.Delete Else ActiveCell.Offset(1, 0).Select End If Next i Application.ScreenUpdating = True End Sub -------------------- This code works fine, but really I would rather hide the row. Whenever I change *Selection.EntireRow.Delete* to *Selection.EntireRow.Hidden = True* it stops after the first row if finds is empty. I would be very grateful if somebody could help me with this. TIA british.assassin -- british.assassi ------------------------------------------------------------------------ british.assassi's Profile: http://www.excelforum.com/member.php...o&userid=28884 View this thread: http://www.excelforum.com/showthread...hreadid=503833 |
Hiding an empty row?
Try:
For i = Rng to 1 step -1 -- Gary''s Student "british.assassi" wrote: Hi I currently use the following code to delete the entire row if it empty in a selection. Code: -------------------- Sub del_empty_row() Rng = Selection.Rows.Count ActiveCell.Offset(0, 0).Select Application.ScreenUpdating = False For i = 1 To Rng If ActiveCell.Value = 0 Then Selection.EntireRow.Delete Else ActiveCell.Offset(1, 0).Select End If Next i Application.ScreenUpdating = True End Sub -------------------- This code works fine, but really I would rather hide the row. Whenever I change *Selection.EntireRow.Delete* to *Selection.EntireRow.Hidden = True* it stops after the first row if finds is empty. I would be very grateful if somebody could help me with this. TIA british.assassin -- british.assassi ------------------------------------------------------------------------ british.assassi's Profile: http://www.excelforum.com/member.php...o&userid=28884 View this thread: http://www.excelforum.com/showthread...hreadid=503833 |
Hiding an empty row?
Sub Hide_empty_row()
Rng = Selection.Rows.Count ActiveCell.Offset(0, 0).Select Application.ScreenUpdating = False For i = 1 To Rng If ActiveCell.Value = 0 Then Selection.EntireRow.Hidden = True End If ActiveCell.Offset(1, 0).Select Next i Application.ScreenUpdating = True End Sub -- Regards, Tom Ogilvy "british.assassi" <british.assassi.221z3m_1137961501.1133@excelfor um-nospam.com wrote in message news:british.assassi.221z3m_1137961501.1133@excelf orum-nospam.com... Hi I currently use the following code to delete the entire row if it empty in a selection. Code: -------------------- Sub del_empty_row() Rng = Selection.Rows.Count ActiveCell.Offset(0, 0).Select Application.ScreenUpdating = False For i = 1 To Rng If ActiveCell.Value = 0 Then Selection.EntireRow.Delete Else ActiveCell.Offset(1, 0).Select End If Next i Application.ScreenUpdating = True End Sub -------------------- This code works fine, but really I would rather hide the row. Whenever I change *Selection.EntireRow.Delete* to *Selection.EntireRow.Hidden = True* it stops after the first row if finds is empty. I would be very grateful if somebody could help me with this. TIA british.assassin -- british.assassi ------------------------------------------------------------------------ british.assassi's Profile: http://www.excelforum.com/member.php...o&userid=28884 View this thread: http://www.excelforum.com/showthread...hreadid=503833 |
Hiding an empty row?
Thanks so much Tom :D -- british.assassi ------------------------------------------------------------------------ british.assassi's Profile: http://www.excelforum.com/member.php...o&userid=28884 View this thread: http://www.excelforum.com/showthread...hreadid=503833 |
All times are GMT +1. The time now is 12:27 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com