+ Reply to Thread
Results 1 to 14 of 14

Hiding row in a sheet based on cell selection in another sheet

  1. #1
    Registered User
    Join Date
    05-22-2012
    Location
    Birmingham, UK
    MS-Off Ver
    Excel 2010
    Posts
    41

    Hiding row in a sheet based on cell selection in another sheet

    Hi

    I have a code working however, a "runtime error" of "13" keep appearing and i cannot figure it out for the life of me. The code i have is;

    Please Login or Register  to view this content.

    The error seems to appear if it type anything into any other cell and then delete it?

    Any help would be greatly appreciated

    Regards

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Hiding row in a sheet based on cell selection in another sheet

    Can't seem to spot any problems, is your worksheet named like this, Pre-start & method statement p3 ? If yes, is the worksheet protected?

  3. #3
    Registered User
    Join Date
    05-22-2012
    Location
    Birmingham, UK
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Hiding row in a sheet based on cell selection in another sheet

    The file is too large to upload apparently

    The sheets are named as they are in the macro and the works sheets are not protected at the moment

  4. #4
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Hiding row in a sheet based on cell selection in another sheet

    Which line is the error highlighting?

  5. #5
    Registered User
    Join Date
    05-22-2012
    Location
    Birmingham, UK
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Hiding row in a sheet based on cell selection in another sheet

    Hi

    Its highlighting
    Please Login or Register  to view this content.

  6. #6
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Hiding row in a sheet based on cell selection in another sheet

    Try changing it to a single line?
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-22-2012
    Location
    Birmingham, UK
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Hiding row in a sheet based on cell selection in another sheet

    Tried - error still showing

  8. #8
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Hiding row in a sheet based on cell selection in another sheet

    I just tried the exact same code and is not getting any error. Maybe post a sample workbook with any huge amount of data removed?

  9. #9
    Registered User
    Join Date
    05-22-2012
    Location
    Birmingham, UK
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Hiding row in a sheet based on cell selection in another sheet

    RAMS (master) - example.xls

    See attached workbook.

    The error occurs when sub-contractors is set to "No" (i.e. to hide the line) and a date is put in to "start date" and then deleted

  10. #10
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Hiding row in a sheet based on cell selection in another sheet

    Odd enough, it's working fine when I try your workbook. Problem could be with the data validations.
    The data validation in the cell for sub-contractors was ripped to this
    Please Login or Register  to view this content.
    when you removed sensitive information (I believe). So I manually changed the validation list to a simple "yes" and "no". When I choose yes, this was properly shown
    Liase with sub-contractors and ensure their RAM's are available. Refer to p2 for permit requirements & p1 for sub-contractor details. PPE and adherence to RAM's to be supervised at all times
    in the worksheet "Pre-start & method statement p3", and likewise, properly hidden when I chose no.

    So now I can't really figure out what's the problem on your side.

  11. #11
    Registered User
    Join Date
    05-22-2012
    Location
    Birmingham, UK
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Hiding row in a sheet based on cell selection in another sheet

    Hi - yes, the code works. The error only appears when another cell on the sheet is populated and then deleted?

  12. #12
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Hiding row in a sheet based on cell selection in another sheet

    Ok. try this.
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    05-22-2012
    Location
    Birmingham, UK
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Hiding row in a sheet based on cell selection in another sheet

    It works!! what was changed?

  14. #14
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Hiding row in a sheet based on cell selection in another sheet

    Well the reason it's throwing an error only when you delete something is because then Target would be a Null/Nothing. And comparing a Null with a string like "No" returns in an error (Type mismatch).
    So moving the checking of "No" into a second If statement will ensure that it goes past the first If statement and is definitely not a Null value as it's validated by the Data validation in cell H26.

+ 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] Help with hiding or unhiding multiple ranges of rows based on cell value on another sheet
    By Jake Bierly in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-22-2013, 12:14 PM
  2. [SOLVED] Hiding Columns / Sheet selection
    By ola7mat in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-19-2012, 05:30 AM
  3. Excel 2007 : Sheet and Cell selection based on date
    By kanight in forum Excel General
    Replies: 1
    Last Post: 04-08-2011, 04:43 AM
  4. Sheet and Cell selection based on date
    By kanight in forum Excel General
    Replies: 1
    Last Post: 04-08-2011, 03:26 AM
  5. Replies: 3
    Last Post: 11-12-2010, 04:31 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