formula for "date created" [SOLVED]

  • Still no-go...here's what is happening starting with a new workbook
    1. Open excel with new workbook
    2. Alt+F11 to open VBE
    3. Double click "ThisWorkbook" in the VBAProject
    4. Under "general" I select "Workbook"
    5. Under "Open" (right payne) I select "Before Print"
    6. Paste this code

    Quote

    Private Sub Workbook_Open()


    Worksheets("Sheet1").Range("A2").Value = Date


    End Sub


    7. Return to workbook, & select "print"
    8. I get returned to the VBE window with an error (below)

    Quote

    Compile error:
    Ambiguous name detected:Workbook_Open
    [OK] [Help]


    9. In the VBE screen "Private Sub Workbook Open" is highlighted.
    10. I can select OK, & it will send the Doc to print, but the "date result" I am seeking is still not present (even after closing, saving, & reopening)


    When I re-open the Book1, I am first taked to the VBE screen, showing the same Compile error. This is driving me crazy...I know I can manually insert (as 2rrs has sugested) the date on a thousand PO's faster than it's taking me to achieve this result...but it's my quest for knowledge now...Please don't give up on me & save my sanity!
    Thanks-Larry

  • Bozo....


    Sounds like you may have got the Workbook_Open code intertwined with the Before_Print code ... hence the problems.


    I am attaching a tested working copy, which inserts date in A3 before printing and A2 on Opening. Have a look at the code in the VBE and compare it to the code that's going wrong for you in your workbook.


    The two sets of code should look like this in the "This Workbook" pane


    Code
    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    Worksheets("Sheet1").Range("A3").Value = Date
    End Sub
    
    
    Private Sub Workbook_Open()
    Worksheets("Sheet1").Range("A2").Value = Date
    End Sub


    Hope this helps :thumbup:

  • :thumbcoo:Thanks so much WillR & the others that have beared with me through this odeal. I finally got it! And along the way I learned a whole new world about VBE code...what a bonus! It seems that the error I was making was I was pasteing the entire like below

    Quote

    Private Sub Workbook_Open()


    Worksheets("Sheet1").Range("A2").Value = Date


    End Sub

    instead of

    Quote

    Worksheets("Sheet1").Range("A2").Value = Date

    thus giving me the Compile error. I even took it one step further to have the date inserted on all four sheets of the workbook by using the "=sheet1 cell location" to place the print date across all four sheets....very kool:thumbcoo:
    Acomplishing this is better than sex.....well close anyway! Thanks again for putting up with this dummy...and I hope to return to this forum again to gain some more knowledge.
    Larry

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!