problem hide specific columns based on cell value(formula)

MKLAQ

Active Member
Joined
Jan 30, 2021
Messages
387
Office Version
  1. 2016
Platform
  1. Windows
hello
I have a problem when I hide columns form c3:ag3 it should hide based on cell value is "TRUE" the cell value contain formula to show "TRUE" I no know if is that possible or not please guide me
VBA Code:
Sub Hide_Columns_Containing_Value()

Dim c As Range

For Each c In Range("c3:ag3").Cells
    If c.Value = "TRUE" Then
        Columns(c.Column).EntireColumn.Hidden = True
    End If
Next c

End Sub
thanks in advance
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Try without the quotes
VBA Code:
 If c.Value = TRUE Then
 
Upvote 0
Solution
Are the values TEXT values of "True" or Boolean values of TRUE?
If Boolean, do not use quotes around the word TRUE, i.e.
VBA Code:
If c.Value = TRUE Then


EDIT: Too slow! Fluff beat me to the punch!
 
Upvote 0
ahh ! that's because the formula
many thanks guys for your assistance :)
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,515
Messages
6,114,080
Members
448,548
Latest member
harryls

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