Save workbook command button with wild card macro

searchlight

Board Regular
Joined
Dec 25, 2009
Messages
112
I have a macro enabled workbook with a file name that starts with the word "data".

I input data to the workbook through the use of a user form. On the user form I have a command button that I click periodically to save my work. (I have the ability to hide the workbook and added the button for this reason)

There are several time I need to open an additional workbook or two to do research and if I click the save button on the user form and the "data" workbook is not active we get a run time error.

Right now I have just the standard macro instructions for the command button:

>Private Sub CommandButton3_Click()

>ActiveWorkbook.Save

>End Sub

Thank!!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
The only thing you need to add is the name of the worksheet you want to save rather than use activesheet.

Code:
Private Sub CommandButton3_Click()

Workbooks("YourDataWorkbook").Save

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,434
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top