+ Reply to Thread
Results 1 to 19 of 19

VBA Hide Function not working

  1. #1
    Forum Contributor
    Join Date
    12-25-2011
    Location
    Lahore, Punjab, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    287

    VBA Hide Function not working

    Hello all gurus

    I have macro that needs to hide all rows that have column A date outside given date range but it is not working.

    Here is macro


    Please Login or Register  to view this content.

    Kindly check
    Attached Files Attached Files
    Last edited by caabdul; 02-22-2018 at 08:43 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,933

    Re: VBA Hide Function not working

    Here's an alternative VBA
    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    12-25-2011
    Location
    Lahore, Punjab, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    287

    Re: VBA Hide Function not working

    Hi Alansidman

    2 questions about your code:
    1- If there are 5000 Rows, will your code be fast?
    2- If those 5000 Rows are already hidden and are outside given date range, will this code unhide those?

    Regards

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,933

    Re: VBA Hide Function not working

    1. Don't know. Time it if that is an issue for you.
    2. this code will not unhide anything.

  5. #5
    Forum Contributor
    Join Date
    12-25-2011
    Location
    Lahore, Punjab, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    287

    Re: VBA Hide Function not working

    Actually I want to hide all dates that are outside given range.

    Strange thing is that this code is working on all other sheets, but on this sheet it just hides Row 8 whatever I do.
    Last edited by caabdul; 02-22-2018 at 03:43 AM.

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,933

    Re: VBA Hide Function not working

    Suggest you add a line of code at the beginning to unhide all hidden lines and then run your code to hide those lines that meet your criteria.

    Strange thing is that this code is working on all other sheets,
    Which code are you referring to? The word "this" does not tell me which code.

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

    Re: VBA Hide Function not working

    Try this
    Please Login or Register  to view this content.
    Actually I want to unhide all dates that are outside given range.
    Code fixed
    Last edited by jindon; 02-22-2018 at 12:39 AM.

  8. #8
    Forum Contributor
    Join Date
    12-25-2011
    Location
    Lahore, Punjab, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    287

    Re: VBA Hide Function not working

    Hi Jindon

    Many thanks, your code works.

    But it is still big confusion why my code is not working. Hope somebody can look into it.

    Regards

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

    Re: VBA Hide Function not working

    1) Wrong range, 2) Not resetting existing filter
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    12-25-2011
    Location
    Lahore, Punjab, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    287

    Re: VBA Hide Function not working

    Which code are you referring to? The word "this" does not tell me which code.
    My Code given at start

  11. #11
    Forum Contributor
    Join Date
    12-25-2011
    Location
    Lahore, Punjab, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    287

    Re: VBA Hide Function not working

    1) Wrong range
    I want to filter starting from Row 10


    1) Wrong range, 2) Not resetting existing filter
    Please check attached file. It is working with same code as I gave in first post.
    Attached Files Attached Files
    Last edited by caabdul; 02-22-2018 at 04:01 AM.

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

    Re: VBA Hide Function not working

    Quote Originally Posted by caabdul View Post
    I want to filter starting from Row 10
    Your original code says
    Please Login or Register  to view this content.
    ???

  13. #13
    Forum Contributor
    Join Date
    12-25-2011
    Location
    Lahore, Punjab, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    287

    Re: VBA Hide Function not working

    That is typo, but replacing it with 10 doesn't help

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

    Re: VBA Hide Function not working

    As I already mentioned, add one line
    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    12-25-2011
    Location
    Lahore, Punjab, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    287

    Re: VBA Hide Function not working

    Ah, at last it worked.

    But if you check my second file "RowHide-Working.xlsm" it is working without adding "activesheet.autofiltermode = false" code. What is happening there?

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

    Re: VBA Hide Function not working

    You have no such code attached to the workbook.

    If it works, perhaps it is not filtered yet.

  17. #17
    Forum Contributor
    Join Date
    12-25-2011
    Location
    Lahore, Punjab, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    287

    Re: VBA Hide Function not working

    Code is attached to file as macro.

    Now

    when I added "activesheet.autofiltermode = false" code to macro of non-working file, it started working. Then I removed this code and that file is still working.

    Now what we can make of it?

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

    Re: VBA Hide Function not working

    Then what's the problem?

    You are uploading the code that has a typo, and the 2nd file with the different range code???

    So, I don't see the cause of the error.

  19. #19
    Forum Contributor
    Join Date
    12-25-2011
    Location
    Lahore, Punjab, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    287

    Re: VBA Hide Function not working

    I don't know but "activesheet.autofiltermode = false" did the trick. It enabled the sheet to accept my macro and after that macro worked even when I removed this small code.

    Anyways, many thanks for your help.

+ 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. Hide Columns Macro - Working on Windows not working on Mac OSX
    By bcadar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-08-2016, 09:05 AM
  2. [SOLVED] Hide / Unhide rows not working
    By PDBartlett in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-01-2014, 09:11 AM
  3. Macro that should hide rows not working well
    By Paco1991 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-17-2014, 04:41 AM
  4. Hide Row not working?
    By zhunter71 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-18-2013, 09:37 AM
  5. Can't hide working sheet
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-07-2010, 12:16 PM
  6. [SOLVED] Hide an entire row - Not working
    By Mark in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-14-2005, 05:05 PM
  7. Userform.Hide not working
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2005, 10:06 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