S
saweetarab
i have the following code which i want to use for hiding rows which
contain the value"0" in a certain column. The following code searches
through the rows and hides the last row with a value of "0" in it but i
need it to do this for other rows, not just the last one. I think it
needs a loop in it aswell.
Sub hide_rows()
If Range("c8") = "0" Then rowhide = 1
If Range("c9") = "0" Then rowhide = 2
If Range("c10") = "0" Then rowhide = 3
If Range("c11") = "0" Then rowhide = 4
If Range("c12") = "0" Then rowhide = 5
If Range("c13") = "0" Then rowhide = 6
If Range("c14") = "0" Then rowhide = 7
If Range("c15") = "0" Then rowhide = 8
If Range("c16") = "0" Then rowhide = 9
If Range("c17") = "0" Then rowhide = 10
If Range("c18") = "0" Then rowhide = 11
If Range("c19") = "0" Then rowhide = 12
vrowhide = ""
For rowselc = 1 To 12
If rowselc = 1 Then vrow = "8:8"
If rowselc = 2 Then vrow = "9:9"
If rowselc = 3 Then vrow = "10:10"
If rowselc = 4 Then vrow = "11:11"
If rowselc = 5 Then vrow = "12:12"
If rowselc = 6 Then vrow = "13:13"
If rowselc = 7 Then vrow = "14:14"
If rowselc = 8 Then vrow = "15:15"
If rowselc = 9 Then vrow = "16:16"
If rowselc = 10 Then vrow = "17:17"
If rowselc = 11 Then vrow = "18:18"
If rowselc = 12 Then vrow = "19:19"
Rows(vrow).EntireRow.Hidden = False
If rowselc = rowhide Then
Rows(vrow).EntireRow.Hidden = True
End If
Next rowselc
End Sub
contain the value"0" in a certain column. The following code searches
through the rows and hides the last row with a value of "0" in it but i
need it to do this for other rows, not just the last one. I think it
needs a loop in it aswell.
Sub hide_rows()
If Range("c8") = "0" Then rowhide = 1
If Range("c9") = "0" Then rowhide = 2
If Range("c10") = "0" Then rowhide = 3
If Range("c11") = "0" Then rowhide = 4
If Range("c12") = "0" Then rowhide = 5
If Range("c13") = "0" Then rowhide = 6
If Range("c14") = "0" Then rowhide = 7
If Range("c15") = "0" Then rowhide = 8
If Range("c16") = "0" Then rowhide = 9
If Range("c17") = "0" Then rowhide = 10
If Range("c18") = "0" Then rowhide = 11
If Range("c19") = "0" Then rowhide = 12
vrowhide = ""
For rowselc = 1 To 12
If rowselc = 1 Then vrow = "8:8"
If rowselc = 2 Then vrow = "9:9"
If rowselc = 3 Then vrow = "10:10"
If rowselc = 4 Then vrow = "11:11"
If rowselc = 5 Then vrow = "12:12"
If rowselc = 6 Then vrow = "13:13"
If rowselc = 7 Then vrow = "14:14"
If rowselc = 8 Then vrow = "15:15"
If rowselc = 9 Then vrow = "16:16"
If rowselc = 10 Then vrow = "17:17"
If rowselc = 11 Then vrow = "18:18"
If rowselc = 12 Then vrow = "19:19"
Rows(vrow).EntireRow.Hidden = False
If rowselc = rowhide Then
Rows(vrow).EntireRow.Hidden = True
End If
Next rowselc
End Sub