Saving Workbook with another name

camalita

New Member
Joined
Apr 8, 2002
Messages
26
Hi,

I have a form which I am using to update a workbook, I have a cmdbutton which adds the record and asks if the user wants to add another record. If the answer is No, the user is asked if the entry is the last entry for the week. If the answer is YES then the workbook is saved as wkbook1-date.xls. What I can't figure out is

How do I close the initial workbook and clear all the data from the worksheet if the entry is the last for the week.

Can anyone help me?

Thanks,

Mareene
This message was edited by camalita on 2002-04-30 08:59
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
So, you've got the message box with the yes-no buttons nailed down. To close the active workbook with no save try:

Code:
thisworkbook.close false

To clear the ranges, simply use code like the following:
Code:
sheet1.[a1].clearcontents

Just change the sheet # and range (cell a1 in this case) to suit your needs.

However, if you don't save the changes (clearing the contents) the workbook won't be saved. Code to save (assuming the path and name already exist) is:

Code:
thisworkbook.save

To save the same workbook with a different name, review the post at the following link. It will save the workbook to the location of your choice based on a cell value.

http://www.mrexcel.com/board/viewtopic.php?topic=6703&forum=2

Hope this helps.

_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue">O</font></font></font>
This message was edited by NateO on 2002-04-30 09:53
 
Upvote 0

Forum statistics

Threads
1,213,561
Messages
6,114,315
Members
448,564
Latest member
ED38

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