Hello,
I have the code below for a user form to enter some data on my sheet "Expenses"
I need these two boxes to insert the data as date and numbers
Is there any way to do this?
Many thanks in advanced
I have the code below for a user form to enter some data on my sheet "Expenses"
- TextBox1 including date as shown on the second code
- Once I enter the data to the sheet, it shows the date as text
- TextBox4 including the amount
- Once I enter the data to the sheet, it shows the number as text
I need these two boxes to insert the data as date and numbers
Is there any way to do this?
Many thanks in advanced
Code:
Private Sub CommandButton1_Click()
Dim MsgBoxResult As Long
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Expenses")
nr = ws.Cells(Rows.Count, 1).End(xlUp).Row + 1
ws.Cells(nr, 1) = Me.TextBox1 'Date
ws.Cells(nr, 2) = Me.TextBox2 'Type
ws.Cells(nr, 3) = Me.TextBox3 'Description
ws.Cells(nr, 4) = Me.TextBox4 'Amount
MsgBoxResult = MsgBox("Your data has been added" & vbCrLf & "Do you need to add more?", vbYesNo)
If MsgBoxResult = vbNo Then
Unload Me
ElseIf MsgBoxResult = vbYes Then
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
Else
End If
End Sub
Private Sub UserForm_Initialize()
Me.TextBox1 = Now
End Sub
Last edited by a moderator: