ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   hide rows with macro (https://www.excelbanter.com/excel-discussion-misc-queries/25811-hide-rows-macro.html)

Macro to hide rows in spreadwsheet

hide rows with macro
 
i want a looping macro that evaluates two columns in each row of the
spreadsheet and if both cell contain zeros hide the row. Basically if col b
or col c is zero hide row otherwise don't hdie and move down one row to
evaluate it,

CLR

You can do this with the Autofilter............whether you want to delete
rows with one zero or two, or whatever........

Data Filter AutoFilter Custom "does not equal" 0.........then if
you want to further massage that result, just copy and paste it over to
another worksheet............

Vaya con Dios,
Chuck, CABGx3



"Macro to hide rows in spreadwsheet" <Macro to hide rows in spreadwsheet
@discussions.microsoft.com wrote in message
...
i want a looping macro that evaluates two columns in each row of the
spreadsheet and if both cell contain zeros hide the row. Basically if col

b
or col c is zero hide row otherwise don't hdie and move down one row to
evaluate it,




JE McGimpsey

You give conflicting criteria - "both cells contain zeros" and "col b or
col c is zero"

Which do you mean?

In article ,
"Macro to hide rows in spreadwsheet" <Macro to hide rows in
spreadwsheet @discussions.microsoft.com wrote:

i want a looping macro that evaluates two columns in each row of the
spreadsheet and if both cell contain zeros hide the row. Basically if col b
or col c is zero hide row otherwise don't hdie and move down one row to
evaluate it,


B.S.R.

I've done this before by putting a formula in a column in the spreadsheet to
evaluate whether or not the row should be hidden, then referencing that
column in the code.

So let's say you put this formula in column "Q":

=IF(AND(B49=0,C49=0),"Y","N")

Then in your macro:

For rowNum = 49 To 778
If Range("Q" & rowNum) = "Y" Then
Range("Q" & rowNum).Select
Selection.EntireRow.Hidden = True
End If
Next rowNum

Make sure you unhide all the rows before calculating the sheet and running
this macro.

"JE McGimpsey" wrote:

You give conflicting criteria - "both cells contain zeros" and "col b or
col c is zero"

Which do you mean?

In article ,
"Macro to hide rows in spreadwsheet" <Macro to hide rows in
spreadwsheet @discussions.microsoft.com wrote:

i want a looping macro that evaluates two columns in each row of the
spreadsheet and if both cell contain zeros hide the row. Basically if col b
or col c is zero hide row otherwise don't hdie and move down one row to
evaluate it,




All times are GMT +1. The time now is 02:11 AM.

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