ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Is there a way to HIDE a row based on a value of a cell ? (https://www.excelbanter.com/excel-discussion-misc-queries/9931-there-way-hide-row-based-value-cell.html)

Reddiance

Is there a way to HIDE a row based on a value of a cell ?
 
Is there an easy way to hide an entire row if, for example, a cell value in
another sheet is set to "Yes" ? This would have to be programmed and not done
manually, as there could be hundreds of rows I would like to hide, depending
on a value from another sheet.

Thanks

Sam

Norman Jones

Hi Reddiance,

It should be possible to supply you with a macro solution, provided that you
supply specific details of the sheet names, the rows to be hidden and the
addresses of the 'trigger' cells etc.


---
Regards,
Norman



"Reddiance" wrote in message
...
Is there an easy way to hide an entire row if, for example, a cell value
in
another sheet is set to "Yes" ? This would have to be programmed and not
done
manually, as there could be hundreds of rows I would like to hide,
depending
on a value from another sheet.

Thanks

Sam




Reddiance

For example: If in the sheet called "Ctrl" in cell a1, the value is "yes",
then hide the rows in the sheet "ToPrint". The rows to hide are every second
row. For example, Hide rows A5, A7, A9, etc. probably for a few hundred rows.
This could probably be done with a Pivot table solution, but I'd like to make
this very simple to the person I'm making the sheet for.

Thanx

"Norman Jones" wrote:

Hi Reddiance,

It should be possible to supply you with a macro solution, provided that you
supply specific details of the sheet names, the rows to be hidden and the
addresses of the 'trigger' cells etc.


---
Regards,
Norman



"Reddiance" wrote in message
...
Is there an easy way to hide an entire row if, for example, a cell value
in
another sheet is set to "Yes" ? This would have to be programmed and not
done
manually, as there could be hundreds of rows I would like to hide,
depending
on a value from another sheet.

Thanks

Sam





Norman Jones

Hi Reddiance,

Try:

Sub Tester()
Dim rng As Range
Dim i As Long

If LCase(Sheets("Ctrl").Range("A1").Value) _
< "yes" Then
Exit Sub
End If

For i = 5 To Sheets("ToPrint").UsedRange.Rows.Count Step 2

If Not rng Is Nothing Then
Set rng = Union(rng, Cells(i, "A"))
Else
Set rng = Cells(i, "A")
End If
Next i

If Not rng Is Nothing Then
rng.EntireRow.Hidden = True
End If

End Sub

---
Regards,
Norman



"Reddiance" wrote in message
...
For example: If in the sheet called "Ctrl" in cell a1, the value is "yes",
then hide the rows in the sheet "ToPrint". The rows to hide are every
second
row. For example, Hide rows A5, A7, A9, etc. probably for a few hundred
rows.
This could probably be done with a Pivot table solution, but I'd like to
make
this very simple to the person I'm making the sheet for.

Thanx

"Norman Jones" wrote:

Hi Reddiance,

It should be possible to supply you with a macro solution, provided that
you
supply specific details of the sheet names, the rows to be hidden and the
addresses of the 'trigger' cells etc.


---
Regards,
Norman



"Reddiance" wrote in message
...
Is there an easy way to hide an entire row if, for example, a cell
value
in
another sheet is set to "Yes" ? This would have to be programmed and
not
done
manually, as there could be hundreds of rows I would like to hide,
depending
on a value from another sheet.

Thanks

Sam







Norman Jones

Hi Reddance,

Try instead:

Sub Tester()
Dim rng As Range
Dim i As Long

If LCase(Sheets("Ctrl").Range("A1").Value) _
< "yes" Then
Exit Sub
End If

With Sheets("ToPrint")
For i = 5 To .UsedRange.Rows.Count Step 2
If Not rng Is Nothing Then
Set rng = Union(rng, .Cells(i, "A"))
Else
Set rng = .Cells(i, "A")
End If
Next i
End With

If Not rng Is Nothing Then
rng.EntireRow.Hidden = True
End If

End Sub

---
Regards,
Norman



"Norman Jones" wrote in message news:...
Hi Reddiance,

Try:

Sub Tester()
Dim rng As Range
Dim i As Long

If LCase(Sheets("Ctrl").Range("A1").Value) _
< "yes" Then
Exit Sub
End If

For i = 5 To Sheets("ToPrint").UsedRange.Rows.Count Step 2

If Not rng Is Nothing Then
Set rng = Union(rng, Cells(i, "A"))
Else
Set rng = Cells(i, "A")
End If
Next i

If Not rng Is Nothing Then
rng.EntireRow.Hidden = True
End If

End Sub

---
Regards,
Norman





All times are GMT +1. The time now is 05:19 PM.

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