problem hide specific columns based on cell value(formula)

MKLAQ

Board Regular
Joined
Jan 30, 2021
Messages
109
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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,915
Office Version
  1. 365
Platform
  1. Windows
Try without the quotes
VBA Code:
 If c.Value = TRUE Then
 
Solution

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
57,023
Office Version
  1. 365
Platform
  1. Windows
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!
 

MKLAQ

Board Regular
Joined
Jan 30, 2021
Messages
109
Office Version
  1. 2016
Platform
  1. Windows
ahh ! that's because the formula
many thanks guys for your assistance :)
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,915
Office Version
  1. 365
Platform
  1. Windows
Glad we could help & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,210
Messages
5,640,872
Members
417,174
Latest member
diegomuser

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
Top