Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Saving Workbook with another name

  1. #1
    New Member
    Join Date
    Apr 2002
    Posts
    26
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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 ]

  2. #2
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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/viewtop...c=6703&forum=2

    Hope this helps.

    _________________
    Cheers, NateO

    [ This Message was edited by: NateO on 2002-04-30 09:53 ]

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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