Hide Columns on CountIF

FrEaK_aCcIdEnT

Board Regular
Joined
May 1, 2012
Messages
100
Been picking my brain, trying to wrap my head around how to accomplish this...

If worksheets("SNList").Range(C3:C94,"7FA")=>1 then worksheets("UT").Columns("AF:AN").hidden = True
End If


I know the above wont work, but I would be very grateful if someone could help me out.

Thanks for any help you can provide. :pray:


I will be "Googling" until I can make it work otherwise. [Brain Fry]
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Maybe

Code:
If WorksheetFunction.CountIf(Worksheets("SNList").Range("C3:C94", "7FA")) >= 1 Then
    Worksheets("UT").Columns("AF:AN").Hidden = True
End If
 
Upvote 0
Maybe

Rich (BB code):
If WorksheetFunction.CountIf(Worksheets("SNList").Range("C3:C94", "7FA")) >= 1 Then
    Worksheets("UT").Columns("AF:AN").Hidden = True
End If


VoG, Thanks for the reply

With the code above applied to the private sub below, I get a "Compile Error: Argument not optional" with the .countif highlighted.

Code:
Private Sub Worksheet_Activate()
If WorksheetFunction[B][COLOR=#0000ff].CountIf[/COLOR][/B](Worksheets("SN List").Range("C3:C94", "7FA")) >= 1 Then
    Worksheets("UT").Columns("AF:AN").Hidden = True
End If
End Sub


This what I came up with that doesn't work either. It is telling me Object variable or With block variable not set.

Code:
Dim EngMdl As Range: EngMdl = Worksheets("SN List").Range("C4:C94")
If Application.CountIf(EngMdl, "7FA") > 0 Then
Worksheets("UT").Columns("AF:AN").Hidden = True
End If

Thanks for any insight into either code! :)
 
Upvote 0
Closing bracket in the wrong place, sorry

Code:
If WorksheetFunction.CountIf(Worksheets("SNList").Range("C3:C94"), "7FA") >= 1 Then
    Worksheets("UT").Columns("AF:AN").Hidden = True
End If
 
Upvote 0

Forum statistics

Threads
1,215,503
Messages
6,125,179
Members
449,212
Latest member
kenmaldonado

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