Can't format a form field as date

Roque

New Member
Joined
Sep 30, 2013
Messages
25
I created a form in VBE to input data in a spreadsheet

Public Sub EnterDataInWorksheet()


'Copy the data of the form to the sheet
Dim r As Range
Dim r1 As Range
Set r = Worksheets("Invoices Data").Range("a1").CurrentRegion
Set r1 = r.Offset(r.Rows.Count, 0)
r1.Cells(1).Value = txtInvoice.Value
r1.Cells(2).Value = txtPartNumber.Value
r1.Cells(3).Value = txtQty.Value
r1.Cells(4).Value = txtArrival.Value


End Sub

The date is entered in the format "dd/mm/yy", but when the information is transferred to the sheet it becomes text.
How do I keep as date?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I take it those are Text Boxes...
Well, those contain....Text..

I'm assuming the txtArrival is the Date you're talking about right?
Try
r1.Cells(4).Value = DateValue(txtArrival.Value)
 
Upvote 0
I take it those are Text Boxes...
Well, those contain....Text..

I'm assuming the txtArrival is the Date you're talking about right?
Try
r1.Cells(4).Value = DateValue(txtArrival.Value)


Works perfectly!
Thank you very much!
 
Upvote 0

Forum statistics

Threads
1,222,749
Messages
6,167,958
Members
452,158
Latest member
MattyM

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top