Consulting

Results 1 to 4 of 4

Thread: Command Button To Save & Close

  1. #1

    Command Button To Save & Close

    Hi Can anyone give me the code for a userform command button to Save data to a worksheet & Close a userform at the same time.

    I have re posted this as I inadvertently posted it in the Access forum earlier

  2. #2
    VBAX Regular kroz's Avatar
    Joined
    Sep 2010
    Posts
    74
    Location
    This saves the workbook and closes it
    [vba]
    sub closewrk()
    ActiveWorkbook.SaveAs Filename:= "Myname.xls"
    Activeworkbook.Close False
    end sub
    [/vba]

    You can create a button and assign this macro to it.

  3. #3
    kroz

    I don't want to close the workbook. What i have is a userform called Employees with another pop up userform to add additional Employees who aren't in the combobox on the Employee userform. What I want to be able to do is save the data entered into the popup userform to the worksheet and clear the data from the popup userform and close and return to the main Employees userform

  4. #4
    VBAX Contributor
    Joined
    Feb 2009
    Posts
    103
    Location
    close a user form:

    try:
    userformname.hide

    userformname.visible = false

    unload userformname

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •