none
Userform Textbox returns weeknum of another textbox RRS feed

  • Question

  • I have a Userform which enables me to add, update or delete data held on a worksheet ("NLIM_Data"). I am trying to do 2 things.

    I have the textbox where the date is added "txtNLIMDate" I would like "txtWeekNum" return the week number of the "txtNLIMDate" textbox.

    Thanks

    Steve

    Wednesday, January 3, 2018 7:13 PM

Answers

  • If you use the US definition of week number (week 1 starts on January 1st):

    Private Sub txtNLIMDate_Change()
        If IsDate(Me.txtNLIMDate) Then
            Me.txtWeekNum = Format(Me.txtNLIMDate, "ww")
        Else
            Me.txtWeekNum = ""
        End If
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by Steve MW Wednesday, January 3, 2018 8:29 PM
    Wednesday, January 3, 2018 8:09 PM

All replies

  • If you use the US definition of week number (week 1 starts on January 1st):

    Private Sub txtNLIMDate_Change()
        If IsDate(Me.txtNLIMDate) Then
            Me.txtWeekNum = Format(Me.txtNLIMDate, "ww")
        Else
            Me.txtWeekNum = ""
        End If
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by Steve MW Wednesday, January 3, 2018 8:29 PM
    Wednesday, January 3, 2018 8:09 PM
  • Hans

    As Always perfection. thank you so much.

    Steve

    Wednesday, January 3, 2018 8:29 PM