Listbox items when a row is selected for Edit it shows on textbox as text but the date display as number

masita

New Member
Joined
Aug 10, 2017
Messages
2
Basically a listbox on a userform that when row is select for edit it displays on the Textbox as text but with the date it display as number 42516 instead of date format has in the cell 12/10/2017 am using DTPicker

Kindly appreciate any idea out there as i was stuck with this for a bit
Thanks everyone
Here is the code
Code:
Private Sub cmdEdit_Click()
Dim lngCol As Long
Dim findvalue As Range
Dim cNum As Integer
Dim DataSH As Worksheet
Dim lRow As Long
Dim srNextRow&, strListBox$, i%


    strListBox = ""
    Sheets("Sheet1").Select


Application.ScreenUpdating = False
Set DataSH = Sheet1


If txtStu1.Value = "" Or txtStu2.Value = "" Then
MsgBox "There is not data to edit"
Exit Sub
End If


Set findvalue = DataSH.Range("A:A"). _
Find(What:=Me.txtStu1.Value, LookIn:=xlValues, LookAt:=xlWhole)
findvalue = txtStu1.Value


findvalue.Offset(0, 1) = txtStu2.Value
findvalue.Offset(0, 2) = txtStu3.Value
findvalue.Offset(0, 3) = txtStu4.Value
findvalue.Offset(0, 4) = txtStu5.Value
findvalue.Offset(0, 5) = txtStu5.Value
'findvalue.Offset(0, 6) = txtStu6.Value
findvalue.Offset(0, 6) = txtStu7.Value
findvalue.Offset(0, 7) = txtStu8.Value
findvalue.Offset(0, 8) = txtStu9.Value
findvalue.Offset(0, 9) = txtStu10.Value
findvalue.Offset(0, 10) = chLeaver.Value
findvalue.Offset(0, 11) = txtStu12.Value


Me.txtStu7.Value = Me.DTPicker1.Value.ToShortDateString
Me.txtStu8.Value = Me.DTPicker2.Value.ToShortDateString
Me.txtStu9.Value = Me.DTPicker3.Value.ToShortDateString
Me.txtStu10.Value = Me.DTPicker4.Value.ToShortDateString
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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