Consulting

Results 1 to 4 of 4

Thread: Get datetimestamp in Excel through VB

  1. #1
    VBAX Regular
    Joined
    Jul 2018
    Posts
    12
    Location

    Get datetimestamp in Excel through VB

    Hi,

    I have a scenario in excel,in which I click a button (Eg: Account), it displays list of accounts.
    Along with this, I need to include a message which gives data time stamp.

    When Account button is clicked, Sub Acc_Upd will be called which inturn calls AccountDet and displays accounts
    and I get pop up with last refresh details. Instead of popup, I need &Now value in a different textbox.

    Can anyone suggest how can I get &Now updated in a different text box when we click 'Account' button.

    Sub Acc_Upd()

    Call AccountDet

    MsgBox "Last refresh was on " & Now

    End Sub

  2. #2
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,158
    Location
    If the code is run from the Userform that has the textbox on then:

    Me.Textbox1.Value = Now()
    Otherwise:

    Userform1.Textbox1.Value = Now()
    Hope this helps
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved

    Excel 365, Version 2401, Build 17231.20084

  3. #3
    VBAX Regular
    Joined
    Jul 2018
    Posts
    12
    Location
    Quote Originally Posted by georgiboy View Post
    If the code is run from the Userform that has the textbox on then:

    Me.Textbox1.Value = Now()
    Otherwise:

    Userform1.Textbox1.Value = Now()
    Hope this helps

  4. #4
    VBAX Regular
    Joined
    Jul 2018
    Posts
    12
    Location
    Thank you. That worked.

Posting Permissions

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