+ Reply to Thread
Results 1 to 4 of 4

Hiding columns in excel 2007 vba

Hybrid View

  1. #1
    Registered User
    Join Date
    05-16-2005
    Posts
    33

    Hiding columns in excel 2007 vba

    I cannot get the code right for this task:
    I can find the last column in a spreadsheet and then I want to hide some previous columns.
    Say the last column number is LastColNo, I then want to hide columns LastColNo-5 to LastColNo-3
    Could someone tell me how to do this please?
    Thanks

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Hiding columns in excel 2007 vba

    Maybe:

    Sub Random_HideColumns():Dim LastColNo As Long
    LastColNo = Columns.Find("*", , , , xlByColumns, xlPrevious).column
    Cells(1, LastColNo - 5).Resize(1, 3).EntireColumn.Hidden = True
    End Sub
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    05-16-2005
    Posts
    33

    Re: Hiding columns in excel 2007 vba

    Great xladept
    Thank you

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Hiding columns in excel 2007 vba

    You're welcome and thanks for the rep!

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Hiding Ribbons in Excel 2007 (VBA)
    By airdyan12 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 10-16-2014, 09:00 AM
  2. Hiding columns in excel without hiding form button
    By rename in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2013, 01:38 AM
  3. Excel 2007 : Hiding a date cell value excel 2007
    By donjjjordan in forum Excel General
    Replies: 1
    Last Post: 05-12-2011, 09:58 AM
  4. Hiding Toolbar in Excel 2007
    By klm9971 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-05-2010, 01:20 PM
  5. Excel 2007 : Hiding and Showing Excel 2007 Ribbon
    By LoveCandle in forum Excel General
    Replies: 8
    Last Post: 01-25-2010, 03:51 AM
  6. Hiding title bar in Excel 2007
    By d3hartm2 in forum Excel General
    Replies: 2
    Last Post: 02-05-2009, 09:47 AM
  7. Hiding Check Boxes In VB excel 2007.
    By Starrysky in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-10-2008, 06:03 PM

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