+ Reply to Thread
Results 1 to 4 of 4

columns hidden

  1. #1
    minostrada
    Guest

    columns hidden

    hello,

    To hide some columns, I'm now using this VB code;

    Private Sub CommandButton4_Click()
    Columns("F:AG").Select
    Selection.EntireColumn.Hidden = True
    CommandButton1.Activate
    End Sub

    Now I also want to hide some columns behind AH:AU. So the columns selection
    has to be "F:AG" and AV:ZZ, but how do I put that in the code?

    Can anybody tell me, it will be very simple but I just don't know!

    Gtrz Marc



  2. #2
    Kevin Lehrbass
    Guest

    RE: columns hidden

    Hi,

    Use a comma between the quotes to have more then one range of columns
    hidden. Change the columns below as necessary.

    Private Sub CommandButton4_Click()
    Range("F:AG,AV:ZZ").Select
    Selection.EntireColumn.Hidden = True
    CommandButton1.Activate
    End Sub

    Cheers,
    --
    Kevin Lehrbass
    www.spreadsheetsolutions4u.com


    "minostrada" wrote:

    > hello,
    >
    > To hide some columns, I'm now using this VB code;
    >
    > Private Sub CommandButton4_Click()
    > Columns("F:AG").Select
    > Selection.EntireColumn.Hidden = True
    > CommandButton1.Activate
    > End Sub
    >
    > Now I also want to hide some columns behind AH:AU. So the columns selection
    > has to be "F:AG" and AV:ZZ, but how do I put that in the code?
    >
    > Can anybody tell me, it will be very simple but I just don't know!
    >
    > Gtrz Marc
    >
    >


  3. #3
    Mike Fogleman
    Guest

    Re: columns hidden

    It is good code practice to avoid selecting things if at all possible, and
    in most cases you can avoid it. Second, you make a list of ranges by
    separating them with a comma.
    Private Sub CommandButton4_Click()
    Range("F:AG, AV:ZZ").EntireColumn.Hidden = True
    CommandButton1.Activate
    End Sub

    Mike F
    "minostrada" <[email protected]> wrote in message
    news:[email protected]...
    > hello,
    >
    > To hide some columns, I'm now using this VB code;
    >
    > Private Sub CommandButton4_Click()
    > Columns("F:AG").Select
    > Selection.EntireColumn.Hidden = True
    > CommandButton1.Activate
    > End Sub
    >
    > Now I also want to hide some columns behind AH:AU. So the columns
    > selection
    > has to be "F:AG" and AV:ZZ, but how do I put that in the code?
    >
    > Can anybody tell me, it will be very simple but I just don't know!
    >
    > Gtrz Marc
    >
    >




  4. #4
    minostrada
    Guest

    Re: columns hidden

    thanks mike and kevin

    "Mike Fogleman" wrote:

    > It is good code practice to avoid selecting things if at all possible, and
    > in most cases you can avoid it. Second, you make a list of ranges by
    > separating them with a comma.
    > Private Sub CommandButton4_Click()
    > Range("F:AG, AV:ZZ").EntireColumn.Hidden = True
    > CommandButton1.Activate
    > End Sub
    >
    > Mike F
    > "minostrada" <[email protected]> wrote in message
    > news:[email protected]...
    > > hello,
    > >
    > > To hide some columns, I'm now using this VB code;
    > >
    > > Private Sub CommandButton4_Click()
    > > Columns("F:AG").Select
    > > Selection.EntireColumn.Hidden = True
    > > CommandButton1.Activate
    > > End Sub
    > >
    > > Now I also want to hide some columns behind AH:AU. So the columns
    > > selection
    > > has to be "F:AG" and AV:ZZ, but how do I put that in the code?
    > >
    > > Can anybody tell me, it will be very simple but I just don't know!
    > >
    > > Gtrz Marc
    > >
    > >

    >
    >
    >


+ 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