April 27, 2024

MoDCore

Welcome to the core

Clear or Reset Cells on your Form

This is some simple code to either “Reset” a user entry workbook or to clear cell values before / after use or on command.
In this example the “reset” is connected to a button for the user once complete will show a message box “Worksheet Reset”, then to move the cursor to Cell C19 ready for the next entry.
Add a simple form button – Here is the developer tab starting point on how to add a button

Code –

Sub Resetbutton()

Application.ScreenUpdating = False
With Worksheets(“ENTER WORKSHEET NAME HERE“)
    .Range(“C19”).ClearContents
    .Range(“E21”).ClearContents
    .Range(“G21”).ClearContents
    .Range(“E20”).Value = “Postcode” ”’adds the word postcode to the cell
    .Range(“C20”).Value = “Select” ”’adds the select to the cell
    .Range(“G15”).Value = “No”

.Range(“G19:G23”).ClearContents

End With

MsgBox (“Worksheet Reset”) ”’Message displayed to the user

Range(“C19”).Select

End Sub

After this code completes you can add extra commands after if you have some standard details like date or username.

Enjoy!

Copyright © All rights reserved. | Newsphere by AF themes.