Solved

Unhide/Hide a column set together Excel

Posted on 2012-04-03
8
369 Views
Last Modified: 2012-04-03
Hello All,

I am trying to unhide/ hide a set of columns - unhide / hide with an ActiveX checkbox in excel 2007.

Private Sub Info1_Click()
If Info1 = True Then

    Columns("D1:G1").Select
    Selection.EntireColumn.Hidden = False
   
    Else:
    Columns("D1:G1").Select
    Selection.EntireColumn.Hidden = True

End If

End Sub

But this code is giving me errors, any ideas? I have attached the excel file.

Thank you
R
Nextbutton-r12.xlsm
0
Comment
Question by:Rayne
  • 5
  • 2
8 Comments
 
LVL 15

Expert Comment

by:gplana
ID: 37802434
Hi. Which errors are you getting ? I think this could help to solve the problem.

Thanks.
0
 

Author Comment

by:Rayne
ID: 37802515
Hello

I get this Run-time Error 1004.

Debugging highlights this line;

Columns("D1:G1").Select
0
 

Author Comment

by:Rayne
ID: 37803382
Any guess??
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 14

Accepted Solution

by:
Tommy Kinard earned 500 total points
ID: 37803459
I got this to work

Private Sub Info1_Click()
    If Info1 = True Then
        Columns("D:G").EntireColumn.Hidden = False
    Else
        Columns("D:G").EntireColumn.Hidden = True
    End If
End Sub
0
 

Author Comment

by:Rayne
ID: 37803475
Thanks Dragon, mush appreciated
0
 

Author Comment

by:Rayne
ID: 37803476
i meant much ;)
0
 
LVL 14

Expert Comment

by:Tommy Kinard
ID: 37803491
LOL no reason to be mushy :)

Thanks for the points and the grade!
0
 

Author Comment

by:Rayne
ID: 37803590
no problem :)
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some time ago I was asked to create a VBA function that would calculate a check digit for an input number, using the following procedure: First, sum up all the individual digits in the number If that sum value has more than one digit, then sum up …
Problem: You created a new custom form in Outlook for your contacts (added fields, deleted fields, changed the layout of fields, whatever) and made it the default form for contacts. The good news is that all new contacts will utilize the new form. T…
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question