Save workbook button on Userform

M

Morlin

I have a Userform that I submit data to. The data can also repopulate
the userform using a Lookup button. What i'd like to make is a button
on the userform that saves the entire workbook. I was hoping it would
be as easy as creating a commandbutton and creating a "save" macro but
it doesn't work. When I hit the save button and then close the entire
workbook my data is not there.

So my question. Can you create a button that will save the workbook
without having to exit to the spreadsheet and hitting save there?

Any help is appreciated.
 
M

Morlin

Never Mind. I figured it out. I was not saving the code under the
correct private sub.

I was just having a brain fart. Here's what I ended up using.

Private Sub CommandButton1_Click()

ActiveWorkbook.save

End Sub
 
P

Per Jessen

Hi

The question is, the Userform in workbook you want to save?

Then you can use this:

ThisWorkbook.Save

otherwise you have to reference to the workbook by name,

Workbooks("MyBook.xls").Save

Hopes this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top