softman

10-14-2010, 05:28 AM

Hi, I have the following code below and it work in one row. I would like to knoe if it 's possibe were I have 2 rows with the following senario:

Colom: G And H

If colom G and H is 0 it stay

If colom G or H is 1 or 0 it stay

If colom Gor H is N/A or 0 it stay

But if colom G or H is both 1 it gets hide

If colom G or H is 1 or N/A it gets hide

Sub HURows()

BeginRow = 6

EndRow = 25

ChkCol = 7

For RowCnt = BeginRow To EndRow

If Cells(RowCnt, ChkCol).Value <= 1 Then

Cells(RowCnt, ChkCol).EntireRow.Hidden = True

Else

Cells(RowCnt, ChkCol).EntireRow.Hidden = False

End If

Next RowCnt

End Sub

Simon said: If all you want to see is zero's left then this will do:

VBA:

Dim i As Long For i = Range("G" & Rows.Count).End(xlUp).Row To 1 Step -1 If Range("G" & i) = 1 Or Range("H" & i) = "N/A" Then Rows(i).Hidden = True End If Next i

I am asking:

Hi Simom

I picked up something: when running the macro it works fine but this is what I get:

If colom G has a N/A and colom H a 1 it does not hide.

but it works the other way..

If colom G has a 1 and colom H a N/A it hides.

Same is working with 0, if N/A and 0 it work fine and does not hide

but if it is 0 and N/A it gets hiden, and should not.

Any idea?

From unsolved link:

http://www.vbaexpress.com/forum/showthread.php?t=34481

Colom: G And H

If colom G and H is 0 it stay

If colom G or H is 1 or 0 it stay

If colom Gor H is N/A or 0 it stay

But if colom G or H is both 1 it gets hide

If colom G or H is 1 or N/A it gets hide

Sub HURows()

BeginRow = 6

EndRow = 25

ChkCol = 7

For RowCnt = BeginRow To EndRow

If Cells(RowCnt, ChkCol).Value <= 1 Then

Cells(RowCnt, ChkCol).EntireRow.Hidden = True

Else

Cells(RowCnt, ChkCol).EntireRow.Hidden = False

End If

Next RowCnt

End Sub

Simon said: If all you want to see is zero's left then this will do:

VBA:

Dim i As Long For i = Range("G" & Rows.Count).End(xlUp).Row To 1 Step -1 If Range("G" & i) = 1 Or Range("H" & i) = "N/A" Then Rows(i).Hidden = True End If Next i

I am asking:

Hi Simom

I picked up something: when running the macro it works fine but this is what I get:

If colom G has a N/A and colom H a 1 it does not hide.

but it works the other way..

If colom G has a 1 and colom H a N/A it hides.

Same is working with 0, if N/A and 0 it work fine and does not hide

but if it is 0 and N/A it gets hiden, and should not.

Any idea?

From unsolved link:

http://www.vbaexpress.com/forum/showthread.php?t=34481