Hey all.
I have this little problem with a userform. It contains two textboxes where the users fill in a start date and a end date.
When I send the dates from these two textboxes to my table it reads it "mm-dd-yyyy" and I want it "dd-mm-yyyy".
I have tried setting the format both in form and in table.
Simple I think, but I just can't figure it out!! As you can see in the code I have tried a few things. Thanks in advance.
(And yes, I am pretty new to VBA)
Private Sub cmbBookUdstyr_Click()
Dim lrDT As Long
'Dim dtDate As Date
lrDT = Sheets("BookingdataUdstyr").Range("A" & Rows.Count).End(xlUp).Row
'dtDate = Format(Date, "dd-mm-yyyy")
'dtDate = DateSerial(Day(Date), Month(Date), Year(Date))
'txtStartUdstyr.Value = dtDate
'txtSlutUdstyr.Value = dtDate
txtStartUdstyr.Value = Format(txtStartUdstyr.Value, "dd-mm-yyyy")
txtSlutUdstyr.Value = Format(txtSlutUdstyr.Value, "dd-mm-yyyy")
'Book.txtStartUdstyr.Value = Format$(Date, "dd-mm-yyyy")
'Book.txtSlutUdstyr.Value = Format$(Date, "dd-mm-yyyy")
If Trim(txtStartUdstyr.Value) = "" Then
txtStartUdstyr.SetFocus
MsgBox "Du mangler startdato"
Exit Sub
End If
If Trim(txtSlutUdstyr.Value) = "" Then
txtSlutUdstyr.SetFocus
MsgBox "Du mangler slutdato"
Exit Sub
End If
Sheets("BookingdataUdstyr").Cells(lrDT + 1, "E").Value = txtStartUdstyr.Value
Sheets("BookingdataUdstyr").Cells(lrDT + 1, "F").Value = txtSlutUdstyr.Value
Dim i As Long
For i = 0 To ListBoxUdstyr.ColumnCount - 1
Sheets("BookingdataUdstyr").Cells(lrDT + 1, "A") = ListBoxUdstyr.Column(0, i)
Sheets("BookingdataUdstyr").Cells(lrDT + 1, "B") = ListBoxUdstyr.Column(1, i)
Next i
Dim e As Long
For e = 0 To ListBoxProduktion.ColumnCount - 1
Sheets("BookingdataUdstyr").Cells(lrDT + 1, "C") = ListBoxProduktion.Column(0, e)
Sheets("BookingdataUdstyr").Cells(lrDT + 1, "D") = ListBoxProduktion.Column(1, e)
Next e
txtStartUdstyr.Text = ""
txtSlutUdstyr.Text = ""
MsgBox "Udstyr er booket"
End Sub
Bookmarks