Auto Hide / UnHide range of Columns based on different cell values

zerlotus

New Member
Joined
Jul 3, 2017
Messages
15
Hello everyone !!

This is my first post ever in this forum, im really new into vb so my question may be easy to solve but not for me.


Im triying to do this :


Check value of cell A1, if it is 0 , hide columns (H and I) , if not, unhide same columns (H and I).

Check Value of Cell A2, if it is 0 , hide columns (J and K) , if not, unhide same columns (J and K).


And so on..

I want this to change in real time, and ive been triying several formulas but none worked .

Could anyone help me ?

Thank you !!

(I've red tons of post in this forum already)
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
This has been the only formula that worked for me :

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Range("A1").Value = 0 Then
        Columns("H:I").EntireColumn.Hidden = True
    Else
        Columns("H:I").EntireColumn.Hidden = False
    End If
End Sub

But i find 2 problems here :

- I dont know how to add consecutive cell check and hide/unhide columns.
- It leaves collumns selected with the blue área if it does not hide them .

Tahnk you
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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