I have a userform that searches for a particular row on my spreadsheet. It then allows me to update the data using the necessary textboxs and then update that specific row by clicking a button. All seems to be working fine, except the date text boxes, which are swapping the day and month fields. (e.g. 01/02/1999 becomes 02/01/1999). I had a similar problem on another sheet and fixed this problem using CDate, however I cannot seem to get this to work for this instance.
Below is the code I am using to "update" the spreadsheet and the specific lines causing me issues are "ws.Cells(r.Row, 12).value = txtCriticalDate.Text" and "ws.Cells(r.Row, 15).value = txtCompleteDate.Text"
Any help on this would really be appreciated.
Private Sub cmdUpdate_Click()
Dim r As Range
Set ws = Worksheets("Opportunities")
Set r = ws.Range("A:A").Find(what:=txtJobRef.Text, LookAt:=xlWhole, MatchCase:=False)
If Not r Is Nothing Then
Application.Calculation = xlCalculationManual
'// Get value in cell r.row, column 2 into textbox2
ws.Cells(r.Row, 1).value = txtJobRef.Text
ws.Cells(r.Row, 2).value = txtCommodity.Text
ws.Cells(r.Row, 3).value = txtSupplier.Text
ws.Cells(r.Row, 4).value = txtCat1.Text
ws.Cells(r.Row, 5).value = txtCat2.Text
ws.Cells(r.Row, 6).value = txtOwner.Text
ws.Cells(r.Row, 7).value = txtBusDept.Text
ws.Cells(r.Row, 8).value = txtSource.Text
ws.Cells(r.Row, 9).value = txtProcRoute.Text
ws.Cells(r.Row, 10).value = txtPlanned.Text
ws.Cells(r.Row, 11).value = txtEstValue.Text
ws.Cells(r.Row, 12).value = txtCriticalDate.Text
ws.Cells(r.Row, 13).value = txtLiveLink.Text
ws.Cells(r.Row, 14).value = txtStatus.Text
ws.Cells(r.Row, 15).value = txtCompleteDate.Text
ws.Cells(r.Row, 16).value = txtWinSup.Text
ws.Cells(r.Row, 17).value = txtActValue.Text
ws.Cells(r.Row, 18).value = txtRoute.Text
ws.Cells(r.Row, 19).value = txtComments.Text
Application.Calculation = xlCalculationAutomatic
End If
End Sub
~~SOLVED~~
Posted literally 2 minutes too soon and worked it out. For anyone with a similar issue,
ws.Cells(r.Row, 12).value = CDate(Me.txtCriticalDate.Value)
worked
Bookmarks