need hide unhide column

have data in columns  from column like this
111222.PNG
then need an button to hide
columns
111222AAA.png

the sequence will continues all over the worksheet
Ad_76984--1-.xlsm
ADRIANA PACCOUNTING ASSISTANTAsked:
Who is Participating?
 
Martin LissConnect With a Mentor Older than dirtCommented:
Replace the code with this.

Sub HideColumns()
    Dim lngCol As Long
    
    Application.ScreenUpdating = False
    
    If ActiveSheet.Shapes("cmdHideUnhide").TextFrame.Characters.Text = "Hide Columns" Then
        For lngCol = 1 To ActiveSheet.UsedRange.Columns.Count
                If Cells(1, lngCol).Interior.Color = 15652797 Then
                    Range(Cells(1, lngCol), Cells(1, lngCol + 5)).EntireColumn.Hidden = True
                    ActiveSheet.Shapes("cmdHideUnhide").TextFrame.Characters.Text = "Unhide Columns"
                End If
            Next
    Else
        For lngCol = 1 To ActiveSheet.UsedRange.Columns.Count
            If Cells(1, lngCol).Interior.Color = 15652797 Then
                Range(Cells(1, lngCol), Cells(1, lngCol + 5)).EntireColumn.Hidden = False
                ActiveSheet.Shapes("cmdHideUnhide").TextFrame.Characters.Text = "Hide Columns"
            End If
        Next
    End If
    
    Application.ScreenUpdating = True
End Sub

Open in new window

1
 
ShumsConnect With a Mentor Distinguished Expert - 2017Commented:
Hi Adriana,

Please Try attached...
Adriana_76984_v2.xlsm
1
 
ADRIANA PACCOUNTING ASSISTANTAuthor Commented:
Shums Thanks expert

i have an situation
 need to hide all columns  in blue color area not just the  the firts
all over the worksheet  ( will be added as needed)
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
Martin LissOlder than dirtCommented:
I wasn't sure where you wanted the button, but you can drag it where ever you want it.
29075969.xlsm
1
 
ADRIANA PACCOUNTING ASSISTANTAuthor Commented:
like these111222AAA.png
0
 
ADRIANA PACCOUNTING ASSISTANTAuthor Commented:
Martin Liss   Thanks !
Glad to see you back

need to hide or unhide

but an sequence will be  the sequence  begings in column b then 31 columns sequence follow
then need to hide or unhide  from 26 to 31 in the sequence
0
 
ADRIANA PACCOUNTING ASSISTANTAuthor Commented:
shums great job !
 but need to have the sequence  all over the worksheet
0
 
Martin LissOlder than dirtCommented:
See if this is better.
29075969a.xlsm
0
 
Martin LissOlder than dirtCommented:
If you don't want column "A" hidden then use this one.
29075969b.xlsm
0
 
Martin LissOlder than dirtCommented:
Note that in post ID: 42419679 I had the wrong file. I corrected it now.
0
 
ADRIANA PACCOUNTING ASSISTANTAuthor Commented:
Martin  after i hit the  button i get this

11223344.PNG
0
 
Martin LissOlder than dirtCommented:
Uncomment the first "For lngCol = 1 to...." line.
0
 
ADRIANA PACCOUNTING ASSISTANTAuthor Commented:
111222AAAbbbbccc.png
0
 
ADRIANA PACCOUNTING ASSISTANTAuthor Commented:
Martin i dont understand  this

how i do that ??

4444.PNG
0
 
ADRIANA PACCOUNTING ASSISTANTAuthor Commented:
Shums  Great  Expert best Expert !!

Martin Liss  Great JOB expert
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.