Consulting

Results 1 to 4 of 4

Thread: update date automatically hen saved

  1. #1
    VBAX Regular
    Joined
    Sep 2016
    Location
    CHENNAI
    Posts
    13
    Location

    update date automatically hen saved

    hi there,

    I am struck across a macro where i need the cell "B2" of "Sheet1" to be updated with the current date in mm.dd.yyyy format only when we save the sheet

    Thanx in advance

  2. #2
    VBAX Expert
    Joined
    Sep 2016
    Posts
    788
    Location
    ThisWorkbook module

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
        If ThisWorkbook.Saved = False Then
          ThisWorkbook.Worksheets("Sheet1").Range("B2").Value = Date
        End If
    End Sub

  3. #3
    VBAX Regular
    Joined
    Sep 2016
    Location
    CHENNAI
    Posts
    13
    Location
    I guess it's not working...

  4. #4
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Quote Originally Posted by msahmed View Post
    I guess it's not working...
    What is that supposed to mean to us? You need to understand that:

    1. We cant see your workbook because you didn't attach one to review,
    2. We are unable to review your code as you didn't post any,
    3. You then post a completely irrelevant statement such as "I guess its not working".

    Since you are asking for assistance, try the following:

    1. Post your workbook, with the relevant section of code that is failing,
    2. Indicate which line/s the code errors out on,
    3. List any error messages you are seeing.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •