+ Reply to Thread
Results 1 to 4 of 4

Auto Date update to replace old date in data sheet via userform

  1. #1
    Forum Contributor
    Join Date
    10-30-2014
    Location
    Pretoria, South Africa
    MS-Off Ver
    Office 365
    Posts
    111

    Auto Date update to replace old date in data sheet via userform

    Good Morning,

    Hope this question finds you well.
    I would really appreciate it if someone can point out to me what I am doing wrong.
    I have a userform that search a data sheets according to comboboxes and then fill in info into textboxes. The user can then change the info in the textbox and once the add button is hit; it will replace the old info with the new info in the data sheet. All this is working fine, but now I would like to include a date stamp on it when the info of that specific choice was last updated. So basically I would like to recall the last date into TextBox4 (as per my selection in the comboboxes), but this time around I would like the date to be automatically replace by today’s date once the user hits the add button.
    I have included the pieces of code that is working and the date one that I can’t get to work.
    Any help would highly be appreciated. Thanks in advance!!

    Private Sub CommandButton1_Click()

    Dim Msg As String, Ans As Variant

    Msg = "Are you sure you want to continue?"

    Ans = MsgBox(Msg, vbYesNo)

    Select Case Ans

    Case vbYes

    Range(BothLB) = TextBox1
    Range(Critical) = TextBox2
    Range(Comments) = TextBox3
    Range(Last_Update) = TextBox4

    Call UserForm_Initialize
    Call ComboBox1_Change
    'Call ComboBox2_Change
    Case vbNo
    GoTo Quit:
    End Select

    Quit:

    End Sub


    Private Sub ComboBox2_Change()
    Dim Rws As Long, Rng As Range, c As Range, s As String

    Rws = Cells(Rows.Count, "B").End(xlUp).Row

    Set Rng = Range(Cells(2, 12), Cells(Rws, 12))
    s = ComboBox2.Value
    For Each c In Rng.Cells
    If c = ComboBox1 And c.Offset(0, -6) = s Then
    TextBox1 = c.Offset(0, -10)
    BothLB = c.Offset(0, -10).Address
    TextBox2 = c.Offset(0, 75)
    Critical = c.Offset(0, 75).Address
    TextBox3 = c.Offset(0, 57)
    Comments = c.Offset(0, 57).Address
    TextBox4 = c.Offset(0, 95)
    Last_Update") = c.Offset(0, 95).Address = Format(Date, "dd/mm/yyyy")

    End If
    Next c
    End Sub

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Auto Date update to replace old date in data sheet via userform

    Hi there,

    I may not have understood your requirements correctly, but try replacing:

    Please Login or Register  to view this content.
    with

    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  3. #3
    Forum Contributor
    Join Date
    10-30-2014
    Location
    Pretoria, South Africa
    MS-Off Ver
    Office 365
    Posts
    111

    Re: Auto Date update to replace old date in data sheet via userform

    Hallo Greg,

    Thanks, that was the answer yes!

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Auto Date update to replace old date in data sheet via userform

    Hi again,

    Many thanks for your feedback - glad I was able to help.

    Regards,

    Greg M

+ 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. Replies: 4
    Last Post: 06-19-2016, 09:39 PM
  2. Replies: 3
    Last Post: 07-01-2013, 01:58 PM
  3. [SOLVED] Retrieving data from sheet into userform and being able to update(replace) that data
    By crobando in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-25-2012, 09:23 AM
  4. [SOLVED] Auto update cell for given date range in next sheet
    By yogananda.muthaiah in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-25-2012, 05:07 AM
  5. Auto replace/update sheet
    By Ivor in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-19-2011, 05:44 AM

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