+ Reply to Thread
Results 1 to 8 of 8

Macro to file values & formats, & alter protection

  1. #1
    Registered User
    Join Date
    12-23-2008
    Location
    Brisbane, Australia.
    MS-Off Ver
    2003
    Posts
    7

    Talking Macro to file values & formats, & alter protection

    Hi Gurus!

    I have a sheet used to process sales orders - about 500 orders per month x ~1.5Mb each. I want to save them as smaller files.

    The sheets to save are full of vlookups linked to external sheets and tabs, other formulas, and macros - most of which do not need saving when the sales order is filed. There are lots of merged cells too.

    I must save:
    1. Cell values
    2. Cell formats incl merged cells, borders, colour, font etc.
    3. The row and column sizes
    4. Print set ups - print area, margins, page setup, header footer etc - (Everything needed to reprint to same as original)

    I think I need a "File save as" style Macro which opens a dialogue box for the user to nominate the destination folder (& allows the user to browse for it), and a new file name.

    The original file name is "Job Sheet - Omlaw.xls"
    The tab/sheet to save is "Front Sheet"
    (There are two other tabs - neither of which need saving.)

    All cells to be changed to "locked".
    The sheet must be password protected in Excel. User to enter it - or not.
    The saved file should be "write protected" if possible?

    What would you recommend?

    Ben
    Last edited by Benb; 12-30-2008 at 09:03 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Ben,

    This macro will create a new new workbook with a copy of "Front Sheet" in it. All cells that have formulas will be cleared, and replaced with their values. The user can select the directory and file name using the "SaveAs" dialog. There are 2 passwords for this file. The file password is used to write protect the workbook. The user will be prompted for this password when the workbook opens. If no password is entered then the workbook is opened as read only. The second password is to protect the sheet. These are set to empty strings in the code and are marked in red in the code. Change these to what ever you want.
    Please Login or Register  to view this content.
    Adding the Macro
    1. Copy the macro above pressing the keys CTRL+C
    2. Open your workbook
    3. Press the keys ALT+F11 to open the Visual Basic Editor
    4. Press the keys ALT+I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Paste the code by pressing the keys CTRL+V
    7. Make any custom changes to the macro if needed at this time.
    8. Save the Macro by pressing the keys CTRL+S
    9. Press the keys ALT+Q to exit the Editor, and return to Excel.

    To Run the Macro...
    To run the macro from Excel, open the workbook, and press ALT+F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    12-23-2008
    Location
    Brisbane, Australia.
    MS-Off Ver
    2003
    Posts
    7

    A debugging issue..

    Thanks for the response Leith!

    I've followed your instructions.
    I needed to unprotect the new sheet - which seems to work, when running it I get ....

    "Run time error '1004':
    Cannot change part of a merged cell."

    The debugger screen looks like:
    Please Login or Register  to view this content.
    Any ideas?

    Merry Christmas to you!

    Ben
    Last edited by Leith Ross; 12-25-2008 at 07:43 PM.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Ben,

    It would help to see how you have your workbook laid out. If you can post a copy of it, I'll review it.

    Sincerely,
    Leith Ross

  5. #5
    Registered User
    Join Date
    12-23-2008
    Location
    Brisbane, Australia.
    MS-Off Ver
    2003
    Posts
    7
    Leith,
    Can I email it to you directly for comment? There are a few confidentiality issues with posting this sheet on the web.

    Ben

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Ben,

    For the forum members benefit, we generally ask that if you have confidential information in your workbook to either remove it or change it before posting the workbook. I realize that sometimes this not possible or practical. Any code I write for you will be posted back here at the forum with an explanation. It would be best if others could see the workbook.

    You can email me at [email protected]

    Sincerely,
    Leith Ross

  7. #7
    Registered User
    Join Date
    12-23-2008
    Location
    Brisbane, Australia.
    MS-Off Ver
    2003
    Posts
    7
    Leith,
    I will send the file to your email address.
    Ben

  8. #8
    Registered User
    Join Date
    12-23-2008
    Location
    Brisbane, Australia.
    MS-Off Ver
    2003
    Posts
    7

    Talking Solved!

    Thanks Leith,

    I've just downloaded it and it works fine first try...thanks so much.
    Yes I think the option to overwrite a file is important as the jobs may be revised by the client and need refiling. So if you can do it - this improvement will put the icing on the cake!

    Regards & thanks again...
    Benb

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1