+ Reply to Thread
Results 1 to 24 of 24

Clear Specific cells automatically after hit a save command button

  1. #1
    Registered User
    Join Date
    09-20-2016
    Location
    Fgura, Malta
    MS-Off Ver
    2013
    Posts
    23

    Clear Specific cells automatically after hit a save command button

    Dear All,

    I made a workbook with 6 worksheets. 3 of them are used to enter information into the other worksheets respectively. In these worksheets made two buttons one of them is used to copy the specific cells and paste them in another worksheet cells. The other one is used to clear specific cells. Both buttons works well but I wish when the user hit the save command button the cells clear automatically. I tried some codes to clear but they didn't work.

    hereunder you can find the code that I used for the save command button and I attach the workbook too with this thread.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    09-22-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 2019
    Posts
    309

    Re: Clear Specific cells automatically after hit a save command button

    Looks like you need to merge and centre when you copy the new file name for a start. Only cell C3 appears to be being copied at the moment.

  3. #3
    Registered User
    Join Date
    09-20-2016
    Location
    Fgura, Malta
    MS-Off Ver
    2013
    Posts
    23

    Re: Clear Specific cells automatically after hit a save command button

    Quote Originally Posted by Frankie_The_Flyer View Post
    Looks like you need to merge and centre when you copy the new file name for a start. Only cell C3 appears to be being copied at the moment.
    all of the cells are copied. The issue is how to clear automatically the cells in SourceArr after the user hit the save button.

    Thanks.

  4. #4
    Forum Contributor
    Join Date
    09-22-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Office 2019
    Posts
    309

    Re: Clear Specific cells automatically after hit a save command button

    Hi marifrad

    How about just calling the ClearSheetsForm macro (or other relevant macro) at the end of the code?

    Please Login or Register  to view this content.
    You can link the other macros to the save buttons on the other sheets.

    May not be very clean but it works!

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,176

    Re: Clear Specific cells automatically after hit a save command button

    Try this..."New Doc Entry" Save Button...Amend for other buttons
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  6. #6
    Registered User
    Join Date
    09-20-2016
    Location
    Fgura, Malta
    MS-Off Ver
    2013
    Posts
    23

    Re: Clear Specific cells automatically after hit a save command button

    Quote Originally Posted by sintek View Post
    Try this..."New Doc Entry" Save Button...Amend for other buttons
    Please Login or Register  to view this content.
    Hi,

    It works. I have another workbook attached with this post similar to the first one but I wish B20 in New Song Entry save as comment in A column instead. It is possible?

    Thank you.
    Attached Files Attached Files
    Last edited by marifard; 06-26-2020 at 07:34 AM.

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,176

    Re: Clear Specific cells automatically after hit a save command button

    Hi marifard

    No need to quote entire posts...Just clutters the thread...
    but I wish specific column save as comment instead
    Explain in more detail please

  8. #8
    Registered User
    Join Date
    09-20-2016
    Location
    Fgura, Malta
    MS-Off Ver
    2013
    Posts
    23

    Re: Clear Specific cells automatically after hit a save command button

    I wish cell B20 in New Song Entry worksheet saves as comment in column A in Scores List worksheet. It is possible with macro?

  9. #9
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,176

    Re: Clear Specific cells automatically after hit a save command button

    This will give you an idea..
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    09-20-2016
    Location
    Fgura, Malta
    MS-Off Ver
    2013
    Posts
    23

    Re: Clear Specific cells automatically after hit a save command button

    Thank you. I tried to implement your code to save in this sheet but it takes me an error. can you guide me? I attach again the workbook.
    Attached Files Attached Files

  11. #11
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,176

    Re: Clear Specific cells automatically after hit a save command button

    With so many cells...loop is easier...
    Please Login or Register  to view this content.
    Last edited by sintek; 06-26-2020 at 08:35 AM.

  12. #12
    Registered User
    Join Date
    09-20-2016
    Location
    Fgura, Malta
    MS-Off Ver
    2013
    Posts
    23

    Re: Clear Specific cells automatically after hit a save command button

    One last thing that I wish to modify. I wish that C6:C17 and F6:F18 didn't make them obligatory. I separate them from rng?

  13. #13
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,176

    Re: Clear Specific cells automatically after hit a save command button

    Change this snippet...
    Please Login or Register  to view this content.
    To...
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    09-20-2016
    Location
    Fgura, Malta
    MS-Off Ver
    2013
    Posts
    23

    Re: Clear Specific cells automatically after hit a save command button

    Thank you sintek. I tried it and works perfect. One thing I wish to resolve. If I leave cell B20 in New Song Entry the code still makes a comment. It is possible if the cell B20 is empty, the code didn't make a comment?

  15. #15
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,176

    Re: Clear Specific cells automatically after hit a save command button

    See if you can figure this one out...

    Put an If statement before this snippet of code...That checks if B20 is not empty
    Please Login or Register  to view this content.

  16. #16
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,176

    Re: Clear Specific cells automatically after hit a save command button

    And...you get it right?

  17. #17
    Registered User
    Join Date
    09-20-2016
    Location
    Fgura, Malta
    MS-Off Ver
    2013
    Posts
    23

    Re: Clear Specific cells automatically after hit a save command button

    I'm feeling stuck about if statement.

  18. #18
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,176

    Re: Clear Specific cells automatically after hit a save command button

    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    09-20-2016
    Location
    Fgura, Malta
    MS-Off Ver
    2013
    Posts
    23

    Re: Clear Specific cells automatically after hit a save command button

    It works

    I made this
    Please Login or Register  to view this content.
    to clear these cells B2:B5, C6:C18, F6:F18. It is possible to apply it for B20 too?

    Thank you.

  20. #20
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,176

    Re: Clear Specific cells automatically after hit a save command button

    Please Login or Register  to view this content.

  21. #21
    Registered User
    Join Date
    09-20-2016
    Location
    Fgura, Malta
    MS-Off Ver
    2013
    Posts
    23

    Re: Clear Specific cells automatically after hit a save command button

    the code gives me an error

    Please Login or Register  to view this content.

  22. #22
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,176

    Re: Clear Specific cells automatically after hit a save command button

    That's because you are merging cells...
    Rule No 1 in Excel...Steer clear from merging cells...Just causes havoc with vba...
    Rather make use of Horizontal Alignment...
    Anyway...This solves...
    Please Login or Register  to view this content.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED...
    Thanks for Rep +
    Last edited by sintek; 06-30-2020 at 03:45 AM.

  23. #23
    Registered User
    Join Date
    09-20-2016
    Location
    Fgura, Malta
    MS-Off Ver
    2013
    Posts
    23

    Re: Clear Specific cells automatically after hit a save command button

    Another thing that I have an error. In the file that I attach, the macro gives me an error when I try to save in New Inv Entry worksheet. The error that gives me an error marked with bold

    Please Login or Register  to view this content.
    Attached Files Attached Files

  24. #24
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,176

    Re: Clear Specific cells automatically after hit a save command button

    That is because your Invoice sheet was protected...Unprotect it and the code works...See attached...

    I think it is time for this thread to be marked as solved...I am not going to sort out all your code for this entire file...

+ 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. Save Userform automatically in PDF and e-mail it via Outlook using Command button
    By olga6542 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-14-2019, 01:52 PM
  2. Need a command button to both Clear and Insert values in specific fields.
    By silverpetals in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-25-2016, 04:00 PM
  3. [SOLVED] Using command button to copy cell contents and paste to different sheet, then clear cells
    By Ethanrholt in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-24-2015, 10:20 AM
  4. Command button to clear lots of cells
    By armsy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-25-2015, 01:57 PM
  5. [SOLVED] Command Button to clear specific cells
    By jamiegfinch in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-21-2014, 09:31 PM
  6. Clear the Specific Range of Cells Using a Command Button
    By Abinaya in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-02-2014, 05:50 AM
  7. Command Button To Save & Clear
    By Mooseman60 in forum Access Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2011, 07:38 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