+ Reply to Thread
Results 1 to 23 of 23

Macro to show & hide rows based if cell B4 equals to "WEEKLY"

  1. #1
    Forum Contributor
    Join Date
    07-28-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365
    Posts
    298

    Smile Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    Hi there, can you please help me with the below?

    Macro to hide rows from 4 to 17 from the tab "Income", if cell B1 in the "Income" tab equals to "WEEKLY".
    If B1 different than "WEEKLY", show rows 4 to 17.

    Thanks

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,552

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    Do you mean like this?
    To Income sheet code module
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    07-28-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365
    Posts
    298

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    I'm getting the error message below because the "Income" tab is protect.
    Any way to run it with the tab protected?

    "Run-time 1004", "Unable to set the hidden property of the range class".

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,552

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-28-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365
    Posts
    298

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    The above works if the tab is protected without password, but if it has password it asks for a password.
    How can I fix the macro above if the tab has a password?

    Cheers

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,552

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    The add password.
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    07-28-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365
    Posts
    298

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    Hi all,

    I'm reviewing this macro, and I kindly ask if someone can help me to add to jindon's macro (see last post) the logic below:
    - if B1 does not equal to "WEEKLY", hide rows 56 to 85 in the "Summary" tab

    Cheers,

  8. #8
    Forum Contributor
    Join Date
    07-28-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365
    Posts
    298

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    Hi all,

    Can someone please help me with the above?

    Thanks,

  9. #9
    Forum Contributor
    Join Date
    07-28-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365
    Posts
    298

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    Hi there,

    Is anyone able to help with that?

    Cheers

  10. #10
    Forum Contributor
    Join Date
    07-28-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365
    Posts
    298

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    Sorry for being annoying, but anyone able to help please?

    Thank you.

  11. #11
    Forum Contributor
    Join Date
    07-28-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365
    Posts
    298

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    Hi there,

    Can someone help today please?

    Thanks

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

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    Maybe if you add this line under the other hide line:

    Please Login or Register  to view this content.
    * If that sheet is also protected, you'll need to unprotect it..........
    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

  13. #13
    Forum Contributor
    Join Date
    07-28-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365
    Posts
    298

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    Thanks xladept, but it didn't work.

    Perhaps because I have the macro in the "Income" sheet code module? See jindon's first post.

    Cheers

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

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    It definitely works - this is the code I ran on the unprotected sheet:

    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    07-28-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365
    Posts
    298

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    Thanks xladept, but I can't get it to work if the Summary tab is protected.
    Is the macro below correct?

    Please Login or Register  to view this content.

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

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    The problem is - how are you going to enter WEEKLY in the Protected Sheet?

    The code unprotects after you vainly entered it and then reprotects before you can try again.

    You'll have to unprotect the sheet at the outset or nothing can be done

    The macro is OK except for the protection code.

  17. #17
    Forum Contributor
    Join Date
    07-28-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365
    Posts
    298

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    Quote Originally Posted by xladept View Post
    The problem is - how are you going to enter WEEKLY in the Protected Sheet?
    Not sure if I understood correctly, but jindon's original code works very well with the protected sheet:
    Please Login or Register  to view this content.
    But doesn't work well if I add the line you suggested:
    Please Login or Register  to view this content.
    In the debug mode, your line is highlighted and the Summary tab is not unprotected.

    Isn't the error related to the fact that the macro is in the Income sheet code module?

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

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    Unprotect the summary sheet too:

    Please Login or Register  to view this content.

  19. #19
    Forum Contributor
    Join Date
    07-28-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365
    Posts
    298

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    That in fact works, but just one last questions: when the macro is running, you can see in a fraction of a second it going to the Summary tab and going back to the Income tab.
    Is there a way to avoid that? I mean, this stuff happening in the blink of an eye looks strange for who doesn't know the background of the macro. Ideally it would happen in the background and it wouldn't show switching tabs.

    Thanks mate!

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

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    You must be really astute - I can't see anything at all when I run it, but I don't know why it would flash the summary tab Have you got other code working at the same time???

  21. #21
    Registered User
    Join Date
    04-28-2014
    Location
    Florida
    MS-Off Ver
    Excel 2007, 2010, 2011 Mac. 2013,2016. I use 2011 and 2016 the most
    Posts
    90

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    Use the Application.ScreenUpdating property in excel

  22. #22
    Forum Contributor
    Join Date
    07-28-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365
    Posts
    298

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    Quote Originally Posted by xladept View Post
    You must be really astute - I can't see anything at all when I run it, but I don't know why it would flash the summary tab Have you got other code working at the same time???
    It is actually pretty noticeable, perhaps if you have a lot of data like I do you can see it very well. But is still a blink of an eye.
    No, nothing else running with this macro.
    Is there anything can be done about it? Our the user will just need to deal with it?

    Quote Originally Posted by Jamesera27 View Post
    Use the Application.ScreenUpdating property in excel
    Sorry mate, can you please give me more information? How can I use that?

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

    Re: Macro to show & hide rows based if cell B4 equals to "WEEKLY"

    All I can think of is; maybe your display options are causing the flicker

+ 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: 5
    Last Post: 02-05-2019, 12:03 AM
  2. [SOLVED] Hide Rows if Cells show nothing or "0"
    By Frankinstyyn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-30-2016, 10:14 AM
  3. Macro to "Group" (hide/show toggle) each marked columns based on an array list.
    By Hyflex in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-07-2016, 09:31 PM
  4. Macro to "Group" (hide/show toggle) each dataset & marked columns.
    By Hyflex in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-02-2016, 01:14 PM
  5. Macro for hide rows with the cell value "aaa"
    By gandreso in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-07-2015, 11:17 AM
  6. Replies: 1
    Last Post: 09-21-2013, 03:18 AM
  7. [SOLVED] Need Macro to compile data from "Weekly" sheets and sum up into "Monthly" summary sheet
    By mo4391 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-21-2013, 07: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