Hide Rows if all values are zero
I am trying to write a macro that will hide a row if certain cells in that
row are all zero. I want the macro to apply to all rows in the worksheet. Can anyone help? |
Hide Rows if all values are zero
Hi,
I am trying to write a macro that will hide a row if certain cells in that row are all zero Would you like to share with us which cells in a row they are? -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "jessica" wrote: I am trying to write a macro that will hide a row if certain cells in that row are all zero. I want the macro to apply to all rows in the worksheet. Can anyone help? |
Hide Rows if all values are zero
Dont have a copy of Excel handy to test, but sounds like you want
something along the lines of: Sub untested() Dim myrange As Range For row = 2 to Range("A65536").End(Xlup).Row myrange = Range(Cells(row,"A"),Cells(row,"d")) If Application.WorksheetFunction.Sum(myrange) = 0 Then myrange.EntireRow.Delete Next End Sub |
Hide Rows if all values are zero
Yes, the cells are in columns F, H, J, L, N, P, R, T, V, X, and Z of each row
(10-131) on a sheet. "Mike H" wrote: Hi, I am trying to write a macro that will hide a row if certain cells in that row are all zero Would you like to share with us which cells in a row they are? -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "jessica" wrote: I am trying to write a macro that will hide a row if certain cells in that row are all zero. I want the macro to apply to all rows in the worksheet. Can anyone help? |
Hide Rows if all values are zero
I tried this and received the error message "Compile error: Next without For"
"Jef Gorbach" wrote: Dont have a copy of Excel handy to test, but sounds like you want something along the lines of: Sub untested() Dim myrange As Range For row = 2 to Range("A65536").End(Xlup).Row myrange = Range(Cells(row,"A"),Cells(row,"d")) If Application.WorksheetFunction.Sum(myrange) = 0 Then myrange.EntireRow.Delete Next End Sub . |
Hide Rows if all values are zero
I tried this and received the error message "Compile error: Next without For"
"Jef Gorbach" wrote: Dont have a copy of Excel handy to test, but sounds like you want something along the lines of: Sub untested() Dim myrange As Range For row = 2 to Range("A65536").End(Xlup).Row myrange = Range(Cells(row,"A"),Cells(row,"d")) If Application.WorksheetFunction.Sum(myrange) = 0 Then myrange.EntireRow.Delete Next End Sub . |
All times are GMT +1. The time now is 07:13 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com