+ Reply to Thread
Results 1 to 5 of 5

Storage and Expiration Date Macro Troubles

  1. #1
    Registered User
    Join Date
    01-29-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    5

    Question Storage and Expiration Date Macro Troubles

    I need to insert a date in the Storage Date column whenever something is added to the Contents List column. Then, the Expiration Date column needs to have the current date plus 60 days. I'm running the following macro in it, but it is not working. Strange part is, I have used this exact same code in other workbooks, and it has worked. Am I not saving it properly? Is there some setting that is not correct? I have attached the workbook to this post. It is also saved as a macro enabled workbook.

    I have noticed that when i click "run", the Worksheet_Change name does not show up in the menu. Is this because it is private? Is Excel not seeing it?

    Private Sub Worksheet_Change(ByVal Target As Range)

    If Not Intersect(Target, Range("D2:D61")) Is Nothing Then

    Target.Offset(0, 1) = Now()
    Target.Offset(0, 2) = Now() + 60

    End If



    End Sub


    Thank you for your help!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Storage and Expiration Date Macro Troubles

    You had the correct name. Yet, it needed to be atached to the worksheet differently. I did that and it works...
    Attached Files Attached Files

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Storage and Expiration Date Macro Troubles

    The macro code is located in the wrong place. It should go in the worksheet's code module and not a standard code module (not Module1)

    Copy your macro code
    Right-click on the Sheet1 worksheet tab
    Select View Code from the pop-up context menu
    Paste the code there in the worksheet's code module.

  4. #4
    Registered User
    Join Date
    01-29-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Storage and Expiration Date Macro Troubles

    Thank you for the help and clarification!

    Does anyone know why the Macro Name area is blank, even though I have a macro? Is that menu for things that go in Module1 and not what I'm trying to do? I attached a screenshot for reference. Empty_Macro_Name.jpg

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Storage and Expiration Date Macro Troubles

    The Private keyword prevents the macro from showing in the macro list.

+ 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