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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ShumsDistinguished 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
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
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

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
Martin LissOlder 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ADRIANA PACCOUNTING ASSISTANTAuthor Commented:
Shums  Great  Expert best Expert !!

Martin Liss  Great JOB expert
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.