+ Reply to Thread
Results 1 to 10 of 10

Problem with Loop Macro to Hide Rows.

  1. #1
    Registered User
    Join Date
    12-09-2011
    Location
    Kilkenny
    MS-Off Ver
    Excel 2007
    Posts
    5

    Problem with Loop Macro to Hide Rows.

    Hi All,

    I have been trying to create a macro to hide blank rows. However I want leave single blank rows where they appear between groups of data. The single blank rows are already in the data set and the large number I want to hide are at the end of the group of data. I created the macro below and it works leaving the single blank rows however when it reaches the multiple blank rows it only hides every other blank row. Here is the code:

    Please Login or Register  to view this content.
    I have tried varying a few parameters to no avail and need some other ideas! Any help would be appreciated!

    Cheers
    James
    Last edited by jt269; 12-09-2011 at 05:11 AM.

  2. #2
    Forum Contributor wamp's Avatar
    Join Date
    11-10-2008
    Location
    Norway
    MS-Off Ver
    97, 2000 & 2003 (diff. workstations)
    Posts
    184

    Re: Problem with Loop Macro to Hide Rows.

    Please read the forum rules and adjust your post accordingly.
    _______________________________________________
    Remember:

    Read the rules!

    Use code tags! Place [CODE] before the first line of code and [/CODE] after the last line of code.

    Mark your post [SOLVED] if it has been answered satisfactorily.
    To do this, click EDIT in your original post, click GO ADVANCED and set the PREFIX. It helps everybody!

    If you are approve (or disapprove) of any members response to your problem, please click the star icon underneath their post and comment. It matters.

  3. #3
    Registered User
    Join Date
    12-09-2011
    Location
    Kilkenny
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Problem with Loop Macro to Hide Rows.

    Sorry about that! I have edited my post.

  4. #4
    Forum Contributor wamp's Avatar
    Join Date
    11-10-2008
    Location
    Norway
    MS-Off Ver
    97, 2000 & 2003 (diff. workstations)
    Posts
    184

    Re: Problem with Loop Macro to Hide Rows.

    doublepost
    Last edited by wamp; 12-09-2011 at 05:41 AM.

  5. #5
    Forum Contributor wamp's Avatar
    Join Date
    11-10-2008
    Location
    Norway
    MS-Off Ver
    97, 2000 & 2003 (diff. workstations)
    Posts
    184

    Re: Problem with Loop Macro to Hide Rows.

    try this (I recommend that you step through the code, to see what values r1 and r2 are, and to check that it does as required..
    also: always perform a backup before running unknown code :-)
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-09-2011
    Location
    Kilkenny
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Problem with Loop Macro to Hide Rows.

    Hi,

    Just getting a runtime 6 overflow error and does not run. If I change the code slightly replacing -2 to 2 in the offsets it runs but then hides the single blank rows.
    Last edited by jt269; 12-09-2011 at 06:29 AM.

  7. #7
    Forum Contributor wamp's Avatar
    Join Date
    11-10-2008
    Location
    Norway
    MS-Off Ver
    97, 2000 & 2003 (diff. workstations)
    Posts
    184

    Re: Problem with Loop Macro to Hide Rows.

    made a small alteration. see example.xls

    (not sure what you want to accomplish with the loops in your original code tho')

  8. #8
    Registered User
    Join Date
    12-09-2011
    Location
    Kilkenny
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Problem with Loop Macro to Hide Rows.

    Hi Wamp,

    I have attached an example of what I am trying to do. I have varying amounts of data (with single blank rows in it which I want to keep) which I paste into an existing template sheet. If the data is only a small amount then I have to scroll down 500+ rows to bring up the footer before printing. I simple want to have a marco to hide the rows after the data whilst keeping my single blank rows.

    i=11 as i want the loop to start in cell B11
    I use the "stop" to stop the loop when it reaches a cell with "stop" in it so that the loop stops before entering the footer.
    Your example works but gives a runtime error.

    Cheers
    James
    Attached Files Attached Files
    Last edited by jt269; 12-09-2011 at 07:19 AM.

  9. #9
    Forum Contributor wamp's Avatar
    Join Date
    11-10-2008
    Location
    Norway
    MS-Off Ver
    97, 2000 & 2003 (diff. workstations)
    Posts
    184

    Re: Problem with Loop Macro to Hide Rows.

    This should work:
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    12-09-2011
    Location
    Kilkenny
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Problem with Loop Macro to Hide Rows.

    Works like a dream! I like how simple you kept it!

    Cheers
    James

+ 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