+ Reply to Thread
Results 1 to 8 of 8

Hide & Unhide cells depending on drop down

  1. #1
    Forum Contributor
    Join Date
    03-16-2012
    Location
    Halifax, UK
    MS-Off Ver
    MS Office 365
    Posts
    206

    Hide & Unhide cells depending on drop down

    Hi
    I have a Risk Assessment sheet within my RAMS workbook.
    This has now to include a checklist of the risks that are present for the current job. Our H&S consultant company wants the sheet to be blank (i.e. no risks showing, just the first detail page and the last signing page) and then as each risk is ticked on the checklist the risks will appear on the next pages.
    I previously had a series of combo tick boxes at the top of the page which hid the risk and inserted blank rows in its place, this worked ok'ish.

    I have created the list on the first page with each risk having a drop down (hidden in col AC) box in the cell next it with the wingdings tick.
    There is a second sheet which will be hidden with all the risks on in the correct order that they appear in the list.
    I want this to copy and paste / insert each risk into the RA sheet starting at cell A42 and keep them neat.
    This needs to work and keep them neatly underneath each other depending on what risks are put in (i.e. not just sequentially).

    What is the best code to do this?

    Kieran
    Last edited by kieranm105; 10-05-2018 at 10:28 AM. Reason: Updated attachment

  2. #2
    Forum Contributor
    Join Date
    03-16-2012
    Location
    Halifax, UK
    MS-Off Ver
    MS Office 365
    Posts
    206

    Re: Hide & Unhide cells depending on drop down

    I have changed the drop downs for activeX checkbox and done this code which works ok for the first one.

    Please Login or Register  to view this content.
    Last edited by kieranm105; 10-05-2018 at 10:29 AM.

  3. #3
    Forum Contributor
    Join Date
    03-16-2012
    Location
    Halifax, UK
    MS-Off Ver
    MS Office 365
    Posts
    206

    Re: Hide & Unhide cells depending on drop down

    Update now with the ActiveX checkbox

    Please Login or Register  to view this content.
    This will copy and paste the risk into the RA sheet from the Risks sheet when the checkbutton is checked. When unchecked it will clear all the area just pasted into.

    If I repeat this for all 35 risks, I will be able to get it to put each one underneath each other, however when I remove each one there will be a space left and the page will look rubbish.

    Any help on this?
    Kieran
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    03-16-2012
    Location
    Halifax, UK
    MS-Off Ver
    MS Office 365
    Posts
    206

    Re: Hide & Unhide cells depending on drop down

    I have all my checkboxes in the workbook now and added page breaks in to get make sure its all on the page correctly.
    they all use the following code with the relevant cells changed.

    Please Login or Register  to view this content.
    This works if I want all 35 risks and then the signing/total pages at the bottom.
    But if one of the risk is taken out it will leave a blank rows, and likewise if you select different risks there will be blank rows.

    What I would like it to do is look for the next blank cell (starting from A42 onwards) and then paste the data in from the 'Risks' sheet.
    Any ideas / help?
    Kieran
    Attached Files Attached Files
    Last edited by kieranm105; 10-08-2018 at 06:22 AM.

  5. #5
    Valued Forum Contributor dotchiejack's Avatar
    Join Date
    05-21-2015
    Location
    Antwerp,Belgium
    MS-Off Ver
    2016
    Posts
    507

    Re: Hide & Unhide cells depending on drop down

    Hi kieranm105,
    Lesson nr. 1 in VBA Avoid Select and activate, it slows down your code big time an it is rarely needed.
    See this example:
    This code
    Please Login or Register  to view this content.
    does exact the same as your code
    Please Login or Register  to view this content.
    Lesson nr 2 keep it simple
    See your title: Hide & Unhide cells depending on drop down, why don't you use it instead of the slow copy paste stuff.
    You don't need the page Risks,because the data is on your Ra page.
    Application.ScreenUpdating = True is not necessary, this goes automaticly.
    See attached.
    Attached Files Attached Files
    Click the * Add Reputation below to say thanks.

  6. #6
    Forum Contributor
    Join Date
    03-16-2012
    Location
    Halifax, UK
    MS-Off Ver
    MS Office 365
    Posts
    206

    Re: Hide & Unhide cells depending on drop down

    Thanks Dotchiejack that's great.
    I got most of the code from the macro recorder, I don't know a lot of the shorter versions yet but getting there! :D

    Kieran

  7. #7
    Valued Forum Contributor dotchiejack's Avatar
    Join Date
    05-21-2015
    Location
    Antwerp,Belgium
    MS-Off Ver
    2016
    Posts
    507

    Re: Hide & Unhide cells depending on drop down

    Glad to help .
    Have a nice day.

  8. #8
    Forum Contributor
    Join Date
    03-16-2012
    Location
    Halifax, UK
    MS-Off Ver
    MS Office 365
    Posts
    206

    Re: Hide & Unhide cells depending on drop down

    I need to have another look at this as it doesn't look good when printing out. There are gaps when I have the print area set and page breaks in.
    Last edited by kieranm105; 10-12-2018 at 10:31 AM.

+ 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 and unhide rows and columns depending on value
    By ElliotH in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2016, 08:05 AM
  2. VBA to hide and unhide rows depending on a value placed in another cell
    By elleb in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-27-2015, 04:43 AM
  3. Hide/Unhide cells based on drop-down list
    By Savvy25 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2014, 02:36 AM
  4. Replies: 10
    Last Post: 09-17-2013, 10:36 AM
  5. [SOLVED] Hide/unhide cells depending on independent cell value
    By aaron061883 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-01-2013, 08:20 PM
  6. unhide cells depending on drop down box value
    By jmatthews in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-19-2012, 06:28 AM
  7. Hide/Unhide Columns Depending on cell value
    By taghos7777 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-13-2009, 08:36 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