+ Reply to Thread
Results 1 to 12 of 12

Automatic week commence date needed

  1. #1
    Registered User
    Join Date
    05-09-2009
    Location
    Glasgow
    MS-Off Ver
    Excel 2003
    Posts
    20

    Automatic week commence date needed

    Attached is a sheet I use for my pubs to send me their financial information.

    Unfortunately, like most staff - they become lazy and need to be kept in line, but when it comes to money, I need it all to work out exactly.

    The sheet seems to almost perfect for what I need now, but for the week commencing date on the bar business sheet.

    This is the master date for all the figures inputed so I need the week commencing date to always be correct from a Monday.

    At the moment the formula I have in ensures that, but when I open it the following Monday to get the figures the date changes to the following Monday from when the sheet was started.

    So...is there a Makro that can run that when you open the sheet for the first time it will ask for the week commencing date which will then lock that date or would it be better inserting another sheet called calendar with week numbers and do a lookup function so that a specific week number relates to a specific week commencing?

    Can you help me with the actual formula/VBA coding if either is possible?

    Thanks
    Attached Files Attached Files
    Last edited by bbarnes81; 05-26-2009 at 09:56 AM. Reason: Infarction problem

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Whats the best way to do this?

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Automatic week commence date needed

    I'm presuming your title change is acceptable since it now depicts your need accurately.

    I am also presuming the sheet you've uploaded is a "template" that must be initialized each week, thus your issue with when it is opened. Adding in a macro will require your users to enable macros on their system or at least when they open the sheet.

    So, if this IS a template, first...UNLOCK cell B1 so that it is editable, clear the cell so that it is empty....then lock your sheet.

    On the Menu Bar just to the left of FILE : EDIT : VIEW : INSERT you will see an Excel icon. Right-click on it and select VIEW CODE. This will open the WorkBook Module for you.

    Now, paste in this code:
    Please Login or Register  to view this content.
    This macro will see the empty cell, add the commencement date, convert it to a real value, and lock the cell so it is no longer changeable.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    05-09-2009
    Location
    Glasgow
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Automatic week commence date needed

    Thanks mudraker - I currently use excel 2007, though can get access to 2003 but not till the weekend, so I don't suppose you know how to decrypt your instructions to 2007 mode?

    Thanks

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Automatic week commence date needed

    The name is JB....
    How to use the macro:
    1. Open up your workbook
    2. Get into VB Editor (Press Alt+F11)
    3. Locate ThisWorkbook in the Project Window on the left...if it's not open press Ctrl-R to open it
    4. Copy and paste in the code (given above)
    5. Get out of VBA (Press Alt+Q)
    6. Follow the other instructions given previously
    7. Save your sheet as an Excel TEMPLATE

    By saving as a template, when you first open the sheet it will be a fresh copy of the template and it will require you to save it with a unique name. The code I gave you will see the empty cell B1, put in the date based on the formula you asked for, then make the data permanent.

    .

  6. #6
    Registered User
    Join Date
    05-09-2009
    Location
    Glasgow
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Automatic week commence date needed

    Thanks JB - sorry about the name confusion, I blame the spreadsheets.

    So I have done everything you said, and it doesn't seem to work?

    I even enabled macros, opened the trust centre and trusted everything to see if that was the problem.

    I have saved it as both macro enabled template and 97-2003 template but neither seem to be picking up the code that has been entered?

    Attached is what I have done.
    Attached Files Attached Files

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Automatic week commence date needed

    So I have done everything you said, and it doesn't seem to work?
    Hehe...let's see...
    Quote Originally Posted by JBeaucaire
    ...if this IS a template, first...UNLOCK cell B1 so that it is editable
    ,
    Cell B1 is still locked...you didn't unlock it.

    Quote Originally Posted by JBeaucaire
    clear the cell so that it is empty....
    That's good, you did that.

    Quote Originally Posted by JBeaucaire
    ...then lock your sheet.
    The sheet isn't locked....

    Quote Originally Posted by JBeaucaire
    On the Menu Bar just to the left of FILE : EDIT : VIEW : INSERT you will see an Excel icon. Right-click on it and select VIEW CODE. This will open the WorkBook Module for you. Now, paste in this code

    ...in the next post:
    3. Locate ThisWorkbook in the Project Window on the left...if it's not open press Ctrl-R to open it
    4. Copy and paste in the code
    I opened the ThisWorkbook Module and it's empty. Seems you pasted it into the Sheet Module for Sheet1. That's not right... hehe. WorkBook_Event macros won't work in sheet modules, and vice versa.

    7. Save your sheet as an Excel TEMPLATE
    The sheet you sent me wasn't saved as a template, it was an XLS.

    So...that's not a good score for doing everything I told you. 1 out of 5...ouch! (prod-poke)

    Anyway, I added a password to your sheet (barpwd) which means I needed to tweak that macro just a bit anyway. Here it is as a template. This means each time you open it, you will be opening a COPY, not the actual original template. So, put the file in your templates directory or on your Desktop where you can double-click it directly.

    You'll know it's opened properly when it opens with the name BarMaster1...Excel adds the number.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    05-09-2009
    Location
    Glasgow
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Automatic week commence date needed

    ok ok digs taken on the chin

    But - when I saved as a template and tried to upload it said invalid file.

    I am wondering if it is because I am using a copy which has had multiple versions saved as it keeps asking me to update and the fact I am now changing it on 2007 version rather than 2003??

    Now that you have sent the sheet - thanks very much, there are other sheets part of it, will I be able to add these in without any hassle??


  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Automatic week commence date needed

    Quote Originally Posted by bbarnes81 View Post
    ok ok digs taken on the chin
    hehe...I love a good ribbing! Glad you've got a sense of humor, not everyone around here does... (glances about nervously)

    But - when I saved as a template and tried to upload it said invalid file.
    YEAH! I noticed the same thing after my response...I had to ZIP the file to get it to upload. Very odd that .XLT is not an accepted file extension.

    Now that you have sent the sheet - thanks very much, there are other sheets part of it, will I be able to add these in without any hassle??
    Um...I don't know, as long as it's not a "follow directions" process, you'll do fine. (hee-haw)

    Actually, all kidding aside... Keep in mind when you save the template to reset the values in B1 and relock the sheet. Even opening the template itself to update it will trigger that workbook_open event. Eh?

  10. #10
    Registered User
    Join Date
    05-09-2009
    Location
    Glasgow
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Automatic week commence date needed

    Aw pants - as I thought I have tried to copy the sheets to your great template, but alas - it seems to want to import from other sources when it opens, and I don't know why but for some reason 2007 doesn't like xlt files but it does like xltm.

    So I now need to go and play with a really slow computer at the parents and build the other sheets round the template and save as template.

    I think that is the easiest way and will hopefully work.

    I will let you know how I get on.

    Thanks so much again

    Bri

    Quote Originally Posted by JBeaucaire View Post
    hehe...I love a good ribbing! Glad you've got a sense of humor, not everyone around here does... (glances about nervously)


    YEAH! I noticed the same thing after my response...I had to ZIP the file to get it to upload. Very odd that .XLT is not an accepted file extension.


    Um...I don't know, as long as it's not a "follow directions" process, you'll do fine. (hee-haw)

    Actually, all kidding aside... Keep in mind when you save the template to reset the values in B1 and relock the sheet. Even opening the template itself to update it will trigger that workbook_open event. Eh?

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Automatic week commence date needed

    I always meant you to use the xltm version for Excel 2007. I can't do that with my version, but you can.

    I hope I didn't leave an external link of some kind in there... check EDIT > LINKS.
    Last edited by JBeaucaire; 05-29-2009 at 06:08 PM.

  12. #12
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Automatic week commence date needed

    I thought the sheet always looked for an EXPENSES sheet of some particular name...down in the EXPENSES column. Reset those formulas to what you need them to be

+ 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