• Clear based on User Input (Excel 2000)

    Author
    Topic
    #362951

    Hi All — and thanks for all the help yesterday …
    (it seems every time I do something with this lounge’s help — I am asked to do something more!) dizzy
    Anyways …
    How can I automatically ask the user if he wants to clear his selections, and if he does, clear cells A16:A300, whenever the user performs a Save. Is this possible.

    Thanks all.

    Viewing 0 reply threads
    Author
    Replies
    • #552483

      You can trap thw Workbook before close event and pop up a message box that will give the option. The following example wll ask kif the selections should be cleared before saving and includes an option to cancel theh save.

      Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
          Action = MsgBox("Clear Selections before Saving ?", vbQuestion + vbYesNoCancel)
          Select Case Action
             Case vbYes
                  Worksheets("Sheet1").Range("A16:A300").ClearContents
              Case vbCancel
                  Cancel = True
          End Select
      End Sub

      That procedure must be placed in the Thisworkbook object’s code module. Also note you may have to change the sheet name (“Sheet1”) above.

      Andrew C

    Viewing 0 reply threads
    Reply To: Clear based on User Input (Excel 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: