+ Reply to Thread
Results 1 to 5 of 5

code to hide specific rows

  1. #1
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    code to hide specific rows

    This is a bit complicated to ask but frankly i cannot figure it out myself, my range starts from row 32 and ends in row 277, i'm trying to have a code that would hide every 2nd row and continue hiding for 4 rows (including the 2nd row) in my range. So keep row 32, 37, 42, 47, 53, 57, 62, 67 ..... etc. visible and at the same time keep rows 33-36, 38-41, 43-46, 48-51, 53-56, 58-61....etc. hidden.

    Of course i can do this with looping but that causes the code lag.

    Thank in advance.

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

    Re: code to hide specific rows

    If you're saying you don't want to use a loop to populate the range array, you can manually type in the rows like:

    Please Login or Register  to view this content.
    If you don't mind using a loop to populate the rows, then hiding them all at once, then:

    Please Login or Register  to view this content.
    Edit: That last sub works if the loop goes to 203. At 208 or higher, I get a 1004 error. Any one know why? Is there a maximum length of a string that can go in Range() or something?
    Last edited by walruseggman; 09-22-2016 at 05:15 PM.
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: code to hide specific rows

    Hello walruseggman,

    This line is where the problem is:
    Please Login or Register  to view this content.
    It does not reference the correct Rows to be hidden. it Shows hde = "33:3638:41"


    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

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

    Re: code to hide specific rows

    Hmmm, not at all what I m seeing. Can you post an example workbook that mirrors those results, please?

  5. #5
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: code to hide specific rows

    @walruseggman,

    I don't have a sample Workbook, tested in a new Book, and the Code stops at this line; Range(hde).EntireRow.Hidden = True, and is highlighted in yellow. Now when you hold your cursor over (hde), it shows that it holds the range as "33:3638:41"

+ 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. VBA to hide specific rows?
    By lazyengineer in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-02-2015, 04:06 PM
  2. [SOLVED] Specific macro or VBA code to hide and unhide rows
    By louvaek in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 11-17-2014, 07:36 AM
  3. [SOLVED] Hide specific Rows in Sheet1 + hide 5 more in Sheet2
    By bluesurger in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 06-02-2014, 07:19 AM
  4. [SOLVED] Enhance existing code to hide rows between specific text
    By MissaLissa in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-24-2014, 03:20 PM
  5. [SOLVED] First unhide all rows - then hide rows based on specific cell value for a range of cells
    By robbiekh in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-22-2013, 05:46 PM
  6. Hide specific Rows
    By Jakes in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-22-2012, 05:22 AM
  7. [SOLVED] Hide rows with 0 value in specific ranges
    By persais in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-16-2012, 02:29 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