+ Reply to Thread
Results 1 to 27 of 27

Delete all

  1. #1
    Registered User
    Join Date
    08-20-2019
    Location
    UK
    MS-Off Ver
    2019
    Posts
    16

    Delete all

    I have a spreadsheet that has evolved over the years with the wonderful help of forum members.

    The time has come to add another function which I have seen in a colleagues spreadsheet but unfortunately I can't pick his brains as he has left the company.
    Here is what I would like to achieve


    1. To create a "delete all" function on the front page to clear the data in that row except for cells J5,M5 & AA5. this function would also have to clear the data in the white cells in the linked sheet (cell AA5)

    2. To have a "Do you really want to do this?" pop up to complete the Delete All function

    3. I plan to add an additional duplicate 17 sheets to this workbook therefore adding the same functionality to rows 6 to 10, 12 to 17 and 19 to 24

    attached is a blank copy of the work book, It has Macros that will no doubt require enabling

    I class my self as a slightly knowledgable excel user but would appreciate guidance on how to copy the functionality to the other rows in part 3 of my request

    Langworth PSAG 2023 ver 3.xlsm

  2. #2
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    523

    Re: Delete all

    Attached is an edited version which deals with the deleting request.

    Re adding the 17 sheets- do you essentially want to duplicate the 'FRONT' sheet 17 times? Are these to be named according to some convention? If you can clarify precise intentions, I might get a chance to look at the coding.
    Attached Files Attached Files
    Excel 365 user. To unblock a downloaded macro-enabled workbook, go to your "Downloads" folder > right click on the workbook name > click 'Properties' > check the 'Unblock' checkbox. You can now open the workbook.

  3. #3
    Registered User
    Join Date
    08-20-2019
    Location
    UK
    MS-Off Ver
    2019
    Posts
    16

    Re: Delete all

    Hi deadlyduck
    This seems to be on the right track
    I've added the 17 sheets but have only added the cell links to the first 3 so you can see what I'm trying to achieve (I'll save the tedious linking for later)
    On the front sheet I would like to see the "Delete all" (with associated popup) at the end of each row, therefore the delete all will only apply to columns in that row and the associated sheet white cells (user accesses via Handover link).
    The sheet tabs will eventually be hidden and the work book protected to minimise error risk from users

    hope this clarifies and thanks for your work so far
    Langworth PSAG 2023 ver 3a.xlsm

  4. #4
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    523

    Re: Delete all

    OK- just to confirm my understanding of what you're looking to achieve with the added sheets.

    1. Do you want a button to automatically add these sheets? If yes, is the button to be displayed somewhere on the 'FRONT' sheet? If no, what event is to trigger the sheet addition procedure?
    2. The added sheets are to link back to individual rows on the FRONT sheet-so, Sheet1 has formulas linking to row 5 of the FRONT sheet, sheet 2 links to row 6 etc. Are the links only those that you have included in the workbook version 3a i.e. you've got formulas in sheet1 cells C5,E5,G5,C6, E8 and G8. Am I correct to assume that no other formulas are required in these added sheets?
    3. If you click the 'Delete all' button on the FRONT sheet for a specific row, is the linked sheet to also be deleted?
    4. Do you want the added sheets to be hidden until the 'Handover' hyperlink is clicked?
    5. Is there a naming convention to be used for each added sheet e.g. Details 1, Details 2 etc?
    Last edited by deadlyduck; 11-26-2023 at 11:37 AM.

  5. #5
    Registered User
    Join Date
    08-20-2019
    Location
    UK
    MS-Off Ver
    2019
    Posts
    16

    Re: Delete all

    Hi deadlyduck
    hope this clarifies things
    1. Do you want a button to automatically add these sheets? If yes, is the button to be displayed somewhere on the 'FRONT' sheet? If no, what event is to trigger the sheet addition procedure?
    The sheets are already added to the last version I uploaded so no I don't need to add more sheets as these relate to a fixed number of data sets

    2. The added sheets are to link back to individual rows on the FRONT sheet-so, Sheet1 has formulas linking to row 5 of the FRONT sheet, sheet 2 links to row 6 etc. Are the links only those that you have included in the workbook
    version 3a i.e. you've got formulas in sheet1 cells C5,E5,G5,C6, E8 and G8. Am I correct to assume that no other formulas are required in these added sheets?I have only added the links to the first 3 sheets for demo purposes, the others I will complete later as this is time consuming

    3. If you click the 'Delete all' button on the FRONT sheet for a specific row, is the linked sheet to also be deleted? the sheet remains but it should also delete the data in the no colour cells. e.g. for each sheet linked to a row, cell content for cell, C4,E4,G4,C6,E6,G6,C8,E8,G8, merged cells (C-G) in rows 10,12,14,16,18,20,22 and 24

    4. Do you want the added sheets to be hidden until the 'Handover' hyperlink is clicked?the sheet tabs will not be visible once active, only accessible via the handover link per row

    5. Is there a naming convention to be used for each added sheet e.g. Details 1, Details 2 etc? as above, they won't be visible so will remain as sheet 1, sheet 2 etc

  6. #6
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    523

    Re: Delete all

    OK.

    I think that the attached version is getting close to what you're looking for but I need to clarify this statement:

    "the sheet remains but it should also delete the data in the no colour cells. e.g. for each sheet linked to a row, cell content for cell, C4,E4,G4,C6,E6,G6,C8,E8,G8, merged cells (C-G) in rows 10,12,14,16,18,20,22 and 24"

    In the sample sheets you supplied, there were only formulae in cells C4,E4,G4,C6,E8,G8. You seem to indicate that there are going to be formulas in other cells.
    To accelerate insertion of formulas, I've added a button at bottom left of the FRONT sheet which uses a macro to automatically add the relevant formulas to each of the 18 sheets added.
    You can test this button's functionality by deleting the sample formulas you show on the added sheets and then clicking the button to reinsert them.
    However, at present, the macro only adds links to the 6 cells your sample supplied. If there are additional cells with formula, please upload a version with 1 sample sheet showing ALL formulas.

    Please note that when you click the 'Delete all' button on the FRONT sheet, the linked sheets will display blanks for any cells linking back to row of the FRONT sheet from which data was deleted.
    This seems to satisfy your requirement to delete the data in the no colour cells. Let me know if I'm misunderstanding.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    08-20-2019
    Location
    UK
    MS-Off Ver
    2019
    Posts
    16

    Re: Delete all

    Hi Deadly duck
    It's nearly there
    The white cells in rows 10,12,14,16,18,20,22 and 24 won't have formula's as they will be free text

    The "Add formula to sheets" has done it's job and thus makes it self redundant, so all sheets have the formulas as required, just need "delete all" to include the rows (white cells) above
    I must admit I wasn't looking forward to the linking job.

    as to the delete all button, I could do with that being visible at the end of each row again with the protective pop up.

    As I work with a group of people who could delete the internet so to speak, it is my intention to lock everything that I don't want them to mess about with otherwise I'll be doing repairs every time I come to work. So all they can do is use drop downs or free text as per cell rules (number formats or text etc).

    thanks for your work so far
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    523

    Re: Delete all

    OK.

    My head is spinning a bit after this so I hope this version has you sorted!

    I added a code which allows you to show or hide the Add formulas to sheets button- to show the button, type "show" in cell C1 of the FRONT sheet (no inverted commas, case sensitive). To hide it, type "hide" (same rules).

    The 'Delete all button is generally visible at the extreme right of the FRONT worksheet, occasionally a little cut off but I ended up not grasping the nature of how it has to be positioned.
    Clicking it deletes any free text from the relevant sheet as well as the specified content on the FRONT sheet.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    08-20-2019
    Location
    UK
    MS-Off Ver
    2019
    Posts
    16

    Re: Delete all

    Hi
    The "delete all" buttons need to sit in the corresponding rows of column AE, I tried moving them but the just bounce back to area to the right. For the front page, anything right of the blue won't be visible on the display screen.
    Just tried testing functionality but I'm getting Runtime Error 1004 popups on every page change

  10. #10
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    523

    Re: Delete all

    I misinterpreted this sentence: "as to the delete all button, I could do with that being visible at the end of each row again with the protective pop up." I understood it to require that the button was visible at the end of the rightmost visible cell. Column AE won't always be visible unless you scroll across. In any case, I've changed the code to have the button automatically stay in column AE.

    What page / what cells are you trying to change that triggers the error? I changed a few random cells on the FRONT sheet and on one of the added sheets- all went OK here.
    Attached Files Attached Files

  11. #11
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    523

    Re: Delete all

    Actually- just remembered that I had commented out one of your timer related codes as it was not allowing me to test something. Apologies! I've uncommented it now in the attached workbook.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    08-20-2019
    Location
    UK
    MS-Off Ver
    2019
    Posts
    16

    Re: Delete all

    the error message gone.
    The timer is one of the critical elements, glad you remembered
    is it possible to have the "delete all" buttons permanantly visible, if not I can add a column header to instruct users
    looks good otherwise

  13. #13
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    523

    Re: Delete all

    Would positioning the 'Delete all' button to the left of the screen (for example on the 'Room' cells) be OK? That way, it would always be visible as the user selects any relevant row. Otherwise, there's a trickyish coding needed to keep it visible on the right of the screen (was thinking earlier about it and might have cracked it but unsure).

  14. #14
    Registered User
    Join Date
    08-20-2019
    Location
    UK
    MS-Off Ver
    2019
    Posts
    16

    Re: Delete all

    Can't see why not but I still need the room drop downs, so an additional column wouldn't be a problem

  15. #15
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    523

    Re: Delete all

    OK.

    The 'Delete all' button could be turned into a smaller shape (like a red circle or square with a white coloured 'X' in it, the well understood concept for 'a delete action). This could be positioned to the right edge of the cell with the patient's name. It would only be visible while the user is on the relevant row and if small enough, wouldn't impeded the entering of a name in that cell. This would avoid the need to edit the delete code (not a huge task but still a task). The button would however not have the 'Delete all' text- just a white coloured 'X' but I think that it would be understood in general that it performs a delete action.

    If that doesn't work, could you would upload a workbook with the new column which will hold the 'Delete all' button in whatever place you find works. I can then modify the code as required.

  16. #16
    Registered User
    Join Date
    08-20-2019
    Location
    UK
    MS-Off Ver
    2019
    Posts
    16

    Re: Delete all

    OK
    Yes I like the red circle /white X idea. I've added another column to the left of the room numbers, I'd rather not use the name cell as we get a lot long names (sorry for the extra task)
    In doing this we can lose column AE
    Attached Files Attached Files

  17. #17
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    523

    Re: Delete all

    OK- here's hoping!

    Does the attached work for you?
    Attached Files Attached Files
    Last edited by deadlyduck; 12-01-2023 at 11:04 AM.

  18. #18
    Registered User
    Join Date
    08-20-2019
    Location
    UK
    MS-Off Ver
    2019
    Posts
    16

    Re: Delete all

    I think we've cracked it
    now to fully test it
    thank you very much for your hard work

  19. #19
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    523

    Re: Delete all

    Good stuff.

    Leave a comment here if you find something that needs sorting.

    Have fun with the use of the workbook!

  20. #20
    Registered User
    Join Date
    08-20-2019
    Location
    UK
    MS-Off Ver
    2019
    Posts
    16

    Re: Delete all

    Hi Deadly Duck
    Finally got time to sit and test this, all looking good apart from 3 cells in sheets 1 to 18.
    Cells E6, G6 & C26 don't clear when "Delete all" is clicked on the front page.
    The data on the test sheet is just some random rubbish for testing purposes.
    Merry Christmas
    Stevejd 58

    Langworth PSAG 2023 ver 3c test sheet .xlsm
    Last edited by stevejd 58; 12-27-2023 at 06:11 PM.

  21. #21
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    523

    Re: Delete all

    Hi Steve,

    Attached should do those extra deletions.

    Happy New Year :-)

  22. #22
    Registered User
    Join Date
    08-20-2019
    Location
    UK
    MS-Off Ver
    2019
    Posts
    16

    Re: Delete all

    Hi Deadlyduck
    another slight glitch, cell E6 in sheets 1,2 & 18 is not deleting.
    I think that just about sorts it apart from a little conditional formatting at my end
    thanks
    Steve

  23. #23
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    523

    Re: Delete all

    Are you sure that cell E6 isn't being deleted? I cannot replicate this error using the workbook ver3c uploaded above and the code definitely includes cell E6 in the free-text deletion procedure. It's also very unusual that some sheets are seeing the content deleted while others are not.

  24. #24
    Registered User
    Join Date
    08-20-2019
    Location
    UK
    MS-Off Ver
    2019
    Posts
    16

    Re: Delete all

    Hmmm, don't know what I did then, seems to be OK, maybe too tired and not thinking straight

  25. #25
    Registered User
    Join Date
    08-20-2019
    Location
    UK
    MS-Off Ver
    2019
    Posts
    16

    Re: Delete all

    Hi deadlyduck
    well just when I thought it was good to go, the boss adds a change.
    I've been asked to add another row (28) for the delete all option in the sheets - Row 28 C to G

    to save me bothering you all the time, could you do me a step by step guide to add/delete to the delete all command?

    Langworth PSAG 2024 ver 1.xlsm

    Thanks in advance
    Last edited by stevejd 58; 01-29-2024 at 04:29 PM.

  26. #26
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    523

    Re: Delete all

    Hello Steve,

    It's actually very easy to update the cells to be deleted on the individual sheets. The relevant code requiring update is in the 'TestDeleteAll' module and the specific macros is called 'Sub DeleteFreeText(TargetSheet As Worksheet)'.
    To add additional cells to be deleted, just use the same format as is shown in the With statement- so, for example, you want to delete cells C28:G28 so you'd add a new line as follows just before the 'End with' statement:

    Please Login or Register  to view this content.
    That's it!

    However, I see that the 'Front' sheet (codename is Sheet1) is protected with a password. To allow VBA to do deletions on this sheet, you will need to add the following code to the 'DeleteRowData' macro, just before the line that starts
    Please Login or Register  to view this content.
    The required line to add is
    Please Login or Register  to view this content.
    Then, at the very end of this same macro, add in the following line of code to reprotect sheet1: Sheet1.protect password:="TypeInThePasswordYouUseToProtectSheet1Here"

  27. #27
    Registered User
    Join Date
    08-20-2019
    Location
    UK
    MS-Off Ver
    2019
    Posts
    16

    Re: Delete all

    Hi deadlyduck
    Management has struck again, in the time since we last communicated my office is no more, it's in the midst of a refit so I have not rolled this out yet.
    In the mean time, "management" have asked for an additional 2 columns (X and Y) to the front sheet, my question is how to add them to the delete all command for the front sheet?

    Langworth PSAG 2024.xlsm
    Attached Files Attached Files
    Last edited by stevejd 58; 04-15-2024 at 05:17 PM. Reason: attachment change

+ 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] Delete Method of Range Class Failed on SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    By BFid in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-06-2021, 11:27 AM
  2. [SOLVED] Adding delete code on userform to delete a row on sheet by selecting item on a listbox
    By darbar76528 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-07-2020, 12:50 PM
  3. VBA code to delete the FILTERED range and moving the cell up (dont Delete entire row)
    By mchilapur in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-14-2015, 07:48 AM
  4. Replies: 1
    Last Post: 11-30-2013, 06:37 AM
  5. [SOLVED] Macro to delete sheets and saves remaining file does not properly delete module
    By pherrero in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-21-2005, 08:12 PM
  6. Replies: 0
    Last Post: 06-21-2005, 01:05 PM
  7. [SOLVED] Re: Macro to delete sheets and saves remaining file does not properly delete module
    By pherrero in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-21-2005, 01:05 PM

Tags for this Thread

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