need marco to hide columns

cybercyn

New Member
Joined
Jan 1, 2003
Messages
4
I have this spreadsheet that contains list of Events in Column D, header in Row 4. After participants responded, their initials are added to Column K onwards and in rows with different events, "x" marks the events they are interested in down the Column K.

I created a filter in D3 that selects one event at a time. How can I hides all the non-participants in that row, preferrably with marco.

Thanks so much!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
I have this spreadsheet that contains list of Events in Column D, header in Row 4. After participants responded, their initials are added to Column K onwards and in rows with different events, "x" marks the events they are interested in down the Column K.

I created a filter in D3 that selects one event at a time. How can I hides all the non-participants in that row, preferrably with marco.

Thanks so much!

Not sure I follow you, especially what appears in Column K the initials or the "x". But maybe this might give you some ideas.

Code:
Sub cybercyn()
'
Dim S As String
Dim i As Long

Dim LR As Long

LR = Cells(Rows.Count, 11).End(xlUp).Row


S = InputBox("Enter The Event Here")

    With Columns("D:D")
        .AutoFilter
        .AutoFilter Field:=1, Criteria1:="S"
    End With
    For i = 3 To LR

            If Range("J" & i).Value = "X" And Range("D" & i).Value = S Then
                Range("J" & i).EntireRow.Hidden = False
            Else
                Range("J" & i).EntireRow.Hidden = True
            End If
    Next i
    
End Sub
 
Upvote 0
Thank you John, unfortunately that's not what I'm looking for...

Instead if i put a value in Row 1, A1=0, B1=0, C1=1, D1=0...
then how can i hide all the columns with zero value in Row 1?

Thanks again!
 
Upvote 0
Re: need help! marco to hide columns with cell value condition per column

I tried to write a simple one and it worked hiding this one column after referencing some forum threads.

If Range("A2").Value = 0 Then
Columns("A").EntireColumn.Hidden = True

But how do I loop this the check all Row 2 in Columns A to CH?
Please help...
 
Upvote 0
Re: need help! marco to hide columns with cell value condition per column

I tried to write a simple one and it worked hiding this one column after referencing some forum threads.

If Range("A2").Value = 0 Then
Columns("A").EntireColumn.Hidden = True

But how do I loop this the check all Row 2 in Columns A to CH?
Please help...


Try this:

Code:
Sub cybercyn()
'
Dim X As Range
Dim Y As Range

Set Y = Range(Range("a2"), Range("ch2"))

    For Each X In Y

            If X.Value = "0" Then X.EntireColumn.Hidden = True
    Next
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top