+ Reply to Thread
Results 1 to 7 of 7

Run a macro auto when i open workbook but one time in whole day

  1. #1
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Run a macro auto when i open workbook but one time in whole day

    hello
    i m using a macro to add today date
    i want run this macro when i open workbook but only one time in a date

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Run a macro auto when i open workbook but one time in whole day

    Hi,

    Have a Cell in your workbook that will be the date that you last opened the workbook.

    In your code of On_Open, check this cell to see if it is the same as todays date. If the dates are the same then don't perform the code.

    If the date in the cell isn't today then run the code and make the cell = today's date.

    I hope that makes sense.
    Last edited by MarvinP; 04-26-2014 at 12:52 AM.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Re: Run a macro auto when i open workbook but one time in whole day

    sorry
    i didn't get the meaning what u want to say

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Run a macro auto when i open workbook but one time in whole day

    Look at the attached and find the code of:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by MarvinP; 04-26-2014 at 10:02 AM.

  5. #5
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Re: Run a macro auto when i open workbook but one time in whole day

    When i opening workbook there is debugging error

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Run a macro auto when i open workbook but one time in whole day

    Hi, haroon2015,

    maybe just alter
    Please Login or Register  to view this content.
    to read
    Please Login or Register  to view this content.
    as you would need to reference a cell instead of a sheet.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  7. #7
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Re: Run a macro auto when i open workbook but one time in whole day

    hello HaHoBe
    nice catch
    works perfect

    thanx a lot +1

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. A macro to auto open and auto close a file with time schedule
    By billj in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-21-2015, 06:01 AM
  2. Auto generate list each time you open workbook
    By RB23804 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-14-2013, 05:16 AM
  3. Replies: 0
    Last Post: 01-07-2013, 01:22 PM
  4. auto run macro when open workbook
    By kaffal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-15-2009, 02:58 AM
  5. [SOLVED] How: open a workbook with auto macro disabled using code?
    By mike_cutting-edge in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-13-2005, 03:06 PM

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