+ Reply to Thread
Results 1 to 6 of 6

VB Code to Hide Columns

  1. #1
    Registered User
    Join Date
    07-29-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2003
    Posts
    3

    VB Code to Hide Columns

    Hi there,

    I am very new to VB coding in Excel so would really appreciate your expertise on this

    I have a spreadsheet where I am hiding certain columns (all on the same worksheet) when a checkbox is ticked, I managed to get it working where there are consecutive columns using the below code:

    Private Sub DomainRequestorColumns_Click()

    If Range("C:S").EntireColumn.Hidden = True Then
    Range("C:S").EntireColumn.Hidden = False
    Else
    Range("C:S").EntireColumn.Hidden = True
    End If

    End Sub

    This works perfectly but I need to add a column AU and I can't for the life of me figure out how to do this?

    Can you perhaps advise me on how I can do this please?

    Thanks in advance,
    Angela
    Last edited by Angel007; 08-17-2011 at 07:40 AM.

  2. #2
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: VB Code to Hide Columns

    Hi,

    You need to read the forum rules, and add code brackets around your code

    You just need to change to this:

    Please Login or Register  to view this content.
    Steffen Thomsen

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: VB Code to Hide Columns

    or only this oneliner:

    Please Login or Register  to view this content.



  4. #4
    Registered User
    Join Date
    07-29-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2003
    Posts
    3

    Thumbs up Re: VB Code to Hide Columns

    Quote Originally Posted by Steffen Thomsen View Post
    Hi,

    You need to read the forum rules, and add code brackets around your code

    You just need to change to this:

    Please Login or Register  to view this content.
    Steffen Thomsen
    Sincere apologies Steffen - will definately remember this next time I post a thread with code.

    Thank-you very much for your reply and resolution (Steffen & snb) - tested recommended solutions and works perfectly.
    Thanks again for the help and prompt response - much appreciated.

    Kind Regards,
    Angela

  5. #5
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: VB Code to Hide Columns

    Hi Angela,

    If your question has been solved then the forum rules state that you need to do the following:

    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.

    Sincerely

    Steffen Thomsen

  6. #6
    Registered User
    Join Date
    07-29-2011
    Location
    South Africa
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: VB Code to Hide Columns

    Thanks Steffen - just done so and I hope correctly
    Currently looking through the forum rules and will ensure all is 100% in accordance when I do post again.

    Kind Regards,
    Angela

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1