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

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,215,352
Messages
6,124,457
Members
449,161
Latest member
NHOJ

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