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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
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,214,911
Messages
6,122,192
Members
449,072
Latest member
DW Draft

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