+ Reply to Thread
Results 1 to 7 of 7

Open file and go directly to TODAY()

  1. #1
    Registered User
    Join Date
    10-03-2010
    Location
    Lison
    MS-Off Ver
    Excel 2007
    Posts
    4

    Open file and go directly to TODAY()

    Hello everyone,

    I am an initiate to VBA in excel, and I am lost in trying to find a solution to my problem. Here is what I want to do:

    The spreadsheet I'm working on has on its second row a calendar of sorts, i.e., in the cell B1 it displays "01-Sep", in the cell B2 "02-Sep" and so forth, all the way through different months.

    I need to find a VBA code that, upon opening the spreadsheet, goes directly to the present date (using the TODAY() function somehow?), so that people don't have to scroll all the way to the present date every time they open the file.

    I realise that this may not be that hard to do, but, being the initiate that I am, I could not fashion any decent solution to this problem.

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Open file and go directly to TODAY()

    Try this bit of code. It must go into the workbook module and used the workbook open event to go to the cell. It is currently set to search on sheet1.

    Note: Sheet1 is the sheet code name - - not the worksheet name (as shown in the tab). Adjust this sheet if needed.

    Please Login or Register  to view this content.
    Last edited by Palmetto; 10-03-2010 at 11:32 AM. Reason: revised code per OP clarification
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Registered User
    Join Date
    10-03-2010
    Location
    Lison
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Open file and go directly to TODAY()

    Thank you Palmetto,

    Unfortunately I posted my message in a hurry and didn't think correctly about what I was typing.

    Here is the real layout of the calendar: in B2 there's the first date (01-Sep), and the dates carry on through the row (so C2, D2, E2, etc., and not B1, B2, etc. as I originally said).

    Obviously the code you posted didn't find the correct date ("Date Not Found"), because it was looking in the wrong place (due to my mistake). I tried changing your code to fit the actual layout, but was unsuccessful.

    As a curiosity, here's what I did: (basically swapped "Rows" with "Columns" and vice-versa, which [predictably] didn't work)

    Please Login or Register  to view this content.

    I'm sorry for the mix-up.
    Last edited by QueDices; 10-03-2010 at 11:12 AM.

  4. #4
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Open file and go directly to TODAY()

    code revised in previous post per your clarification.

  5. #5
    Registered User
    Join Date
    10-03-2010
    Location
    Lison
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Open file and go directly to TODAY()

    Unfortunately it did not work. I tinkered around a bit with the code, but couldn't make it work either (it always says "Date not found").

    I attached an .xlsm file with the simplified version of the calendar, maybe it will be helpful.

    Thanks for the attention so far.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    09-18-2010
    Location
    Kalamazoo, MI
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: Open file and go directly to TODAY()

    It wouldn't find properly because the cells were not formatted to match the value of "date" in VB. Attached is a fixed copy. Hope this helps!
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    10-03-2010
    Location
    Lison
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Open file and go directly to TODAY()

    Okay, that's embarrassing. I thought Excel searched for the absolute value of the date, and didn't care about the formatting.

    Anyways, problem solved! Thank you both for your help.

+ 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