+ Reply to Thread
Results 1 to 10 of 10

Macro will not hide all rows

  1. #1
    Registered User
    Join Date
    03-18-2021
    Location
    Aberdeenshire
    MS-Off Ver
    10
    Posts
    21

    Question Macro will not hide all rows

    Morning all,

    I am using code in my sheet to hide rows:

    Please Login or Register  to view this content.
    and much the same to unhide (the code is included in the example workbook).

    For some reason on this worksheet with this code I cannot figure out a way to hide all the rows where row "J/K" is empty. I have tried adding in another column (I) where I put an if statement produce either a "1" or "0" and then change the code to act on this column instead but I still cannot get all the rows to hide.

    The reason I am now seeing this problem (I think) is because I want to be able to enter values in column "B" but not have a price for them, and thus those rows to be hidden. In the example workbook as is rows 68 and 81 will not hide with the macros I currently have.

    I am fairly new to VBA and actually got this code from good old google. So any help would be greatly appreciated.

    Thankyou!!
    Attached Files Attached Files
    Last edited by Nataliec27; 03-31-2021 at 04:52 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,510

    Re: Macro will not hide all rows

    Sorry, response not suitable ... thought you were deleting rows.
    Last edited by TMS; 03-31-2021 at 05:07 AM.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Macro will not hide all rows

    Hi
    What about
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    03-18-2021
    Location
    Aberdeenshire
    MS-Off Ver
    10
    Posts
    21

    Re: Macro will not hide all rows

    Thankyou for your reply.

    I have tried this in column "L" (12), where the formula returns "" if one of the other cells is empty however, it did not work and I still could not hide those rows!!

  5. #5
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: Macro will not hide all rows

    Hello Natalie,

    I believe that the problem is the merged cells (Columns J:K). Merged cells create havoc within VBA and should be avoided altogether. Try un-merging the cells then run the code.

    Cheerio,
    vcoolio.

  6. #6
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Macro will not hide all rows

    Please Login or Register  to view this content.
    ??????

  7. #7
    Registered User
    Join Date
    03-18-2021
    Location
    Aberdeenshire
    MS-Off Ver
    10
    Posts
    21

    Re: Macro will not hide all rows

    Thankyou vcoolio., I did try this and it did not work.

  8. #8
    Registered User
    Join Date
    03-18-2021
    Location
    Aberdeenshire
    MS-Off Ver
    10
    Posts
    21

    Re: Macro will not hide all rows

    Thankyou Mohadin - I used this code, but changed it to column 2 and it now works.

  9. #9
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Macro will not hide all rows

    You are welcome
    Glad I could help
    Thank you for the feedback
    be happy & safe

  10. #10
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: Macro will not hide all rows

    Hi Natalie,

    I just received notification of your reply.

    Thanks for the feed-back and the rep.

    I feel that the loop-type code may be a little slow so, if you're interested, you can use AutoFilter to do the same job. The following codes are based on your idea of using Column I with the 1 or 0 criteria:-

    Please Login or Register  to view this content.
    and

    Please Login or Register  to view this content.
    The end result is the same.

    If you're happy with your solution in posts #6 and 8 then just keep the above up your sleeve for future reference.

    I hope that this helps.

    Cheerio,
    vcoolio.

+ 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. [SOLVED] Macro to Hide rows with zeros in column E5:E50, then Unhide all rows
    By aaron061883 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-30-2019, 01:53 AM
  2. [SOLVED] Macro for Hide blank rows and Unhide the rows with cells
    By Neilesh Kumar in forum Excel General
    Replies: 4
    Last Post: 04-12-2017, 06:06 AM
  3. Need help creating macro to hide rows based upon whether 1 of 3 rows have data
    By BigEdJr in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 01-17-2014, 02:58 PM
  4. Replies: 0
    Last Post: 05-10-2013, 12:04 PM
  5. [SOLVED] Macro to hide Zero Rows
    By Mile029 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 11-19-2012, 02:44 PM
  6. Using check boxes to hide and un-hide rows with drop down lists within rows
    By Sparky_Chris in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2012, 07:22 AM
  7. Macro to Hide and Unhide Rows but still be able to insert rows
    By majasmi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-01-2011, 09:25 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