ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Hide Rows based on value, but not using autofilter (https://www.excelbanter.com/excel-worksheet-functions/248163-hide-rows-based-value-but-not-using-autofilter.html)

Richhall[_2_]

Hide Rows based on value, but not using autofilter
 
Hi, I have seen a number of posts on this but still can't quite get
what I want.

I have a sheet with maybe 20 rows at the top with statistics in, that
I need to display. Then below here is my actual data. I have a
column with from row 21 down with TRUE or FALSE in. On the click of a
button I want to change the sheet so that all rows with FALSE in are
hidden. I cant use autofilter as this also hides the rows at the
top. I have a named range for the column which has TRUE or FALSE in,
and so have the following code, but it does not work:

Range("DisplayStart").Activate
For Each c In Range("DisplayRange")
If c.Value = "FALSE" Then
c.Select
c.EntireRow.Hidden = True
End If
Next

Any ideas please?

Cheers

Rich

Don Guillett

Hide Rows based on value, but not using autofilter
 
Since you didn't say HOW the FALSE comes about this will cover formulas and
text

Sub HideRowsIfFalse()
For i = Cells(Rows.Count, "b") _
..End(xlUp).Row To 1 Step -1
If Cells(i, "b").Value = "FALSE" _
Or Cells(i, "b").Formula = False Then
Rows(i).Hidden = True
End If
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Richhall" wrote in message
...
Hi, I have seen a number of posts on this but still can't quite get
what I want.

I have a sheet with maybe 20 rows at the top with statistics in, that
I need to display. Then below here is my actual data. I have a
column with from row 21 down with TRUE or FALSE in. On the click of a
button I want to change the sheet so that all rows with FALSE in are
hidden. I cant use autofilter as this also hides the rows at the
top. I have a named range for the column which has TRUE or FALSE in,
and so have the following code, but it does not work:

Range("DisplayStart").Activate
For Each c In Range("DisplayRange")
If c.Value = "FALSE" Then
c.Select
c.EntireRow.Hidden = True
End If
Next

Any ideas please?

Cheers

Rich



Tom Hutchins

Hide Rows based on value, but not using autofilter
 
Are the TRUE and FALSE entries text or actual True/False values? If they are
actual True/False values and you are testing for the text "FALSE", the macro
won't find any. Try this:

Dim c As Range
For Each c In Range("DisplayRange")
If c.Value = False Then
c.EntireRow.Hidden = True
End If
Next

Hope this helps,

Hutch

"Richhall" wrote:

Hi, I have seen a number of posts on this but still can't quite get
what I want.

I have a sheet with maybe 20 rows at the top with statistics in, that
I need to display. Then below here is my actual data. I have a
column with from row 21 down with TRUE or FALSE in. On the click of a
button I want to change the sheet so that all rows with FALSE in are
hidden. I cant use autofilter as this also hides the rows at the
top. I have a named range for the column which has TRUE or FALSE in,
and so have the following code, but it does not work:

Range("DisplayStart").Activate
For Each c In Range("DisplayRange")
If c.Value = "FALSE" Then
c.Select
c.EntireRow.Hidden = True
End If
Next

Any ideas please?

Cheers

Rich
.



All times are GMT +1. The time now is 09:20 AM.

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