![]() |
Hide the line when cell B is empty
I would be grateful if someone could provide me with code that will hide a
line when a particular cell (e.g. B) is empty. |
Hide the line when cell B is empty
Sub hiderowifcolempty()
For i = Cells(Rows.Count, "b").End(xlUp).Row To 1 Step -1 If Len(Application.Trim(Cells(i, "b"))) < 1 Then _ Rows(i).Hidden = True Next i End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "Christine" wrote in message ... I would be grateful if someone could provide me with code that will hide a line when a particular cell (e.g. B) is empty. |
Hide the line when cell B is empty
That works nicely. Could you tell me how to specify to hide only rows 5 to
10 when cell b is empty? "Don Guillett" wrote: Sub hiderowifcolempty() For i = Cells(Rows.Count, "b").End(xlUp).Row To 1 Step -1 If Len(Application.Trim(Cells(i, "b"))) < 1 Then _ Rows(i).Hidden = True Next i End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "Christine" wrote in message ... I would be grateful if someone could provide me with code that will hide a line when a particular cell (e.g. B) is empty. |
Hide the line when cell B is empty
You just need to change one line (the For statement):
Sub hiderowifcolempty() For i = 10 To 5 Step -1 If Len(Application.Trim(Cells(i, "B"))) < 1 Then _ Rows(i).Hidden = True Next i End Sub Hope this helps, Hutch "Christine" wrote: That works nicely. Could you tell me how to specify to hide only rows 5 to 10 when cell b is empty? "Don Guillett" wrote: Sub hiderowifcolempty() For i = Cells(Rows.Count, "b").End(xlUp).Row To 1 Step -1 If Len(Application.Trim(Cells(i, "b"))) < 1 Then _ Rows(i).Hidden = True Next i End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "Christine" wrote in message ... I would be grateful if someone could provide me with code that will hide a line when a particular cell (e.g. B) is empty. |
Hide the line when cell B is empty
Thank you both, Don and Tom.
"Tom Hutchins" wrote: You just need to change one line (the For statement): Sub hiderowifcolempty() For i = 10 To 5 Step -1 If Len(Application.Trim(Cells(i, "B"))) < 1 Then _ Rows(i).Hidden = True Next i End Sub Hope this helps, Hutch "Christine" wrote: That works nicely. Could you tell me how to specify to hide only rows 5 to 10 when cell b is empty? "Don Guillett" wrote: Sub hiderowifcolempty() For i = Cells(Rows.Count, "b").End(xlUp).Row To 1 Step -1 If Len(Application.Trim(Cells(i, "b"))) < 1 Then _ Rows(i).Hidden = True Next i End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "Christine" wrote in message ... I would be grateful if someone could provide me with code that will hide a line when a particular cell (e.g. B) is empty. |
All times are GMT +1. The time now is 04:51 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com