+ Reply to Thread
Results 1 to 10 of 10

Only specific columns are hidden based on range

  1. #1
    Forum Contributor
    Join Date
    12-11-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    517

    Only specific columns are hidden based on range

    Hi, i have this code below but its not working the way i want it to work. Im trying to select the last used column to 12 columns before that column and hide them. Need help, thanks

    Please Login or Register  to view this content.

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    9,858

    Re: Only specific columns are hidden based on range

    Hi biznez

    Wanna give this a try
    Please Login or Register  to view this content.
    Last edited by sintek; 04-05-2017 at 12:30 PM. Reason: Took lastcol setting out of loop
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor
    Join Date
    12-11-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    517

    Re: Only specific columns are hidden based on range

    Hey sinek, im getting error message. Only the first column is hidden and then error message

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    9,858

    Re: Only specific columns are hidden based on range

    Did you adapt the code to suite your requirements.i.e. Change
    Please Login or Register  to view this content.
    to your sheetname.
    Upload your file so that we can take a look.

  5. #5
    Forum Contributor
    Join Date
    12-11-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    517

    Re: Only specific columns are hidden based on range

    yes i changed that. it runs fine fo 1st column but error message when looping to next column.

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    9,858

    Re: Only specific columns are hidden based on range

    Herewith sample file that tests fine
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Only specific columns are hidden based on range

    Since the code looks for the last column in row 1, I'm guessing @biznez's worksheet only has the first column in row 1 filled. thus the code's ability to hide the first column, but then in the next iteration would error at Columns(0). Change Cells(1,) to whatever row better represents the last column of your data.

    But of course this is just a guess w/o seeing the data.
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  8. #8
    Forum Contributor
    Join Date
    12-11-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    517

    Re: Only specific columns are hidden based on range

    Thanks guys the sample file helped

  9. #9
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    9,858

    Re: Only specific columns are hidden based on range

    @ walruseggman

    That is very possible....Thanks. Did not think of that. It then would defeat the object of he's request....
    Im trying to select the last used column to 12 columns before

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    9,858

    Re: Only specific columns are hidden based on range

    Glad it helped. thanks for rep points.

+ 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. Replies: 8
    Last Post: 07-12-2015, 09:45 AM
  2. Create New Sheet with specific rows and columns hidden
    By tkensen89 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-15-2015, 11:08 PM
  3. macro to copy range hidden paste in a specific location
    By graiggoriz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-26-2014, 11:27 AM
  4. Replies: 0
    Last Post: 01-15-2014, 05:17 PM
  5. How to delete specific columns based on a named range of values from a worksheet
    By dronofrio in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-12-2012, 10:56 AM
  6. [SOLVED] Hide columns based on cell value - Unable to set hidden range property of Range Class
    By trillium in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-13-2012, 11:13 PM
  7. [SOLVED] Macro to copy a specific range from a hidden sheet
    By dumblonde in forum Excel General
    Replies: 7
    Last Post: 05-10-2012, 02:50 AM

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