+ Reply to Thread
Results 1 to 10 of 10

VBA to automatically hide rows based on text

  1. #1
    Registered User
    Join Date
    05-12-2013
    Location
    Horsham
    MS-Off Ver
    Excel 2013
    Posts
    42

    VBA to automatically hide rows based on text

    I am looking to place a code in a worksheet that when it sees "x" in C10 it automatically hides rows 9 - 21. This process is the same for:

    C23 Rows 22 - 34

    C36 Rows 35 - 47

    C49 Rows 48 - 60

    C62 Rows 61 - 73

    C75 Rows 74 - 86

    C88 Rows 87 - 99

    C101 Rows 100 - 112

    C114 Rows 113 - 125

    C127 Rows 126 - 138

    All worksheets are hidden and password protected "ADMIN" and there is a planning sheet where the X is placed and all the above main cells have for example =PLANNING!F23

    The idea is that on the main PLANNING sheet the user will enter X for not available and then it will be hidden from view if it has anything else or is blank then it will be visible. Also I would like to know where to place the code as the are 7 sheets MONDAY - SUNDAY

    Thanks

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: VBA to automatically hide rows based on text

    Put this in the "Planning" worksheet module:
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    05-12-2013
    Location
    Horsham
    MS-Off Ver
    Excel 2013
    Posts
    42

    Re: VBA to automatically hide rows based on text

    Thanks for that, I have inserted it in the module but must have done something wrong as it has no effect. I have attached the worksheet for you to have a look at as it may be clearer?

    Kind regards & Thanks again

    Will
    Attached Files Attached Files

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: VBA to automatically hide rows based on text

    Your VBA project is password protected...

    You did change this line, didn't you:
    Please Login or Register  to view this content.

    In your case, this should read:
    Please Login or Register  to view this content.
    But obviously, I can't check this, as your code is password protected...

  5. #5
    Registered User
    Join Date
    05-12-2013
    Location
    Horsham
    MS-Off Ver
    Excel 2013
    Posts
    42

    Re: VBA to automatically hide rows based on text

    :-) Nope clearly not paying attention! Password is MASTER

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: VBA to automatically hide rows based on text

    Okay - so change that xRng line, as I already suggested:
    Please Login or Register  to view this content.

    Move the following to the TOP of the worksheet module:
    Please Login or Register  to view this content.

    And change the lower case "x" to an upper case "X" in this line:
    Please Login or Register  to view this content.

    Then it does exactly what you want.

    Note that detail is everything! "x" <> "X", and you need to read the code in replies, not just paste it...

  7. #7
    Registered User
    Join Date
    05-12-2013
    Location
    Horsham
    MS-Off Ver
    Excel 2013
    Posts
    42

    Re: VBA to automatically hide rows based on text

    I have tried amending but still not having any joy. Sorry!

  8. #8
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: VBA to automatically hide rows based on text

    Can you upload the workbook that you have made the changes to, please?

    I'm afraid I can't upload attachments from this PC, but I can check the changes you have made, and test them here.

  9. #9
    Registered User
    Join Date
    05-12-2013
    Location
    Horsham
    MS-Off Ver
    Excel 2013
    Posts
    42

    Re: VBA to automatically hide rows based on text

    wow brill...Thanks it was lower case on the sheet names, I changed them to upper case and it works perfectly!!!

  10. #10
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: VBA to automatically hide rows based on text

    Hmmmm. Case of sheet names shouldn't make any difference... Anyway. Glad you got it working.

+ 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. Automatically hide and unhide rows based on value in cell
    By kmham in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 11-28-2014, 12:03 PM
  2. Automatically Hide Rows Based On Dropdown Box Selection
    By tstram in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-21-2014, 06:13 PM
  3. Automatically Hide Rows based on formula results
    By anjoseph9626 in forum Excel General
    Replies: 2
    Last Post: 02-09-2014, 04:48 PM
  4. [SOLVED] hide rows automatically based on a value in that row
    By jimboryan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-22-2013, 05:13 AM
  5. Automatically hide rows based on criteria before printing
    By scaffdog845 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-07-2011, 01:44 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