ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro to hide all rows that have a cell value of "complete" (https://www.excelbanter.com/excel-programming/386279-re-macro-hide-all-rows-have-cell-value-complete.html)

Maax

macro to hide all rows that have a cell value of "complete"
 
Hi Vergel,

many thanks for your reply. However i can not make it work.
i want each row to be hidden in this range A2 to Q2

i entered your code using the VBA option and assigned it to a button but its
not doing anything?




"Vergel Adriano" wrote:

As an example, the following code will hide/unhide rows where the cell in
column A has "Complete"

Sub toggle_hidden_rows()
Dim c As Range
For Each c In ActiveSheet.Range("A1:A100")
If c.Value = "Complete" Then
With c.EntireRow
.Hidden = Not .Hidden
End With
End If
Next c
End Sub


--
Hope that helps.

Vergel Adriano


"Maax" wrote:

Hello all, I wonder if it is possible to create a macro that would toggle
rows from hidden to unhidden? I would like the button to hide all rows that
have a particular cell as "complete". If this requires 2 seperate buttons
that is not a problem.
I think i may need to have a range in for the row (A1 to M1 for example) as
i have some data already hidden beyond M1 (used in drop down lists).

any help would be much appreciated.

thanks



Tom Ogilvy

macro to hide all rows that have a cell value of "complete"
 
A2 to Q2 is a single row??? Maybe you meant hide columns although it seems
unlikely:

Sub CommandButton1_Click()
Dim c As Range
For Each c In ActiveSheet.Range("A2:Q2")
If c.Value = "Complete" Then
With c.EntireColumn
.Hidden = Not .Hidden
End With
End If
Next c
End Sub

Please clarify what you want.

--
Regards,
Tom Ogilvy


"Maax" wrote:

Hi Vergel,

many thanks for your reply. However i can not make it work.
i want each row to be hidden in this range A2 to Q2

i entered your code using the VBA option and assigned it to a button but its
not doing anything?




"Vergel Adriano" wrote:

As an example, the following code will hide/unhide rows where the cell in
column A has "Complete"

Sub toggle_hidden_rows()
Dim c As Range
For Each c In ActiveSheet.Range("A1:A100")
If c.Value = "Complete" Then
With c.EntireRow
.Hidden = Not .Hidden
End With
End If
Next c
End Sub


--
Hope that helps.

Vergel Adriano


"Maax" wrote:

Hello all, I wonder if it is possible to create a macro that would toggle
rows from hidden to unhidden? I would like the button to hide all rows that
have a particular cell as "complete". If this requires 2 seperate buttons
that is not a problem.
I think i may need to have a range in for the row (A1 to M1 for example) as
i have some data already hidden beyond M1 (used in drop down lists).

any help would be much appreciated.

thanks




All times are GMT +1. The time now is 01:43 AM.

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