Facing Runtime Error - 13, Type of Mismatch

bala04msw

New Member
Joined
Aug 27, 2016
Messages
17
Dear Experts,

This is duplicate thread originally posted in VBA express forum and link is http://www.vbaexpress.com/forum/sho...Type-Mismatch-quot-while-edit-and-update-user

Kindly help me to resolve this issue.

I have developed user form for data entry purposes and its works fine with store data in excel worksheet. Now, i have added the edit option to update the data, if any changes. Here i am facing two issues and as follows:


1. In the edit code: There is a field called Time in and Time out, While i retrieve the data, time is coming as "0.25" instead of "06.00"
2. After edit the user form, i want to update the corrected data in the same row of the excel worksheet. But i am facing Run-time error '13' Type mismatch, while update the changing. especially in this code of line (rowselect = rowselect + 1)

Data is retrieved to edit based on Report Number: "2907201845PU" (Example)

I have used the following code for edit:
Code:
[COLOR=#333333]Private Sub btnSVedit_Click()
 Dim r As Variant
        With Sheets("SVReport")
        r = Application.Match(txtsearchreportno, .Range("A:A"), 0)
        If IsError(r) Then
            MsgBox txtsearchreportno, vbExclamation, "No Match Found"
        Else
            cbtown.Text = .Range("B" & r).Value
            cbdistrict.Text = .Range("C" & r).Value
            cbstate.Text = .Range("D" & r).Value
            cbfacilityname.Text = .Range("E" & r).Value
            txttypeofsite.Text = .Range("F" & r).Value
            txttypeoffacility.Text = .Range("G" & r).Value
            txtsvetanasiteid.Text = .Range("H" & r).Value
            txtsimsid.Text = .Range("I" & r).Value
            txthivpulseid.Text = .Range("J" & r).Value
            txtdate.Text = .Range("K" & r).Value
            txtreportno.Text = .Range("A" & r).Value
            txttimein.Text = .Range("L" & r).Value
            txttimeout.Text = .Range("M" & r).Value
            cbsvdonebyname.Text = .Range("N" & r).Value
            cbsvdonebydesignation.Text = .Range("O" & r).Value
            txtsvothers.Text = .Range("P" & r).Value
            obdoctor.Value = .Range("W" & r).Value
            'etc.
        End If
    End With
End Sub[/COLOR]
I have used the following code for update:

Code:
[COLOR=#333333]Private Sub btnupdate_Click()
If Me.txtsearchreportno.Value = "" Then
MsgBox "Report No. Can Not be Blank!!!", vbExclamation, "Report No"
Exit Sub
End If
ReportNo = Me.txtsearchreportno.Value
Sheets("SVReport").Select
Dim rowselect As Long
Dim msg As String
Dim ans As String
rowselect = Me.txtsearchreportno.Value
rowselect = rowselect + 1
Rows(rowselect).Select
Cells(rowselect, 1) = Me.textreportno.Value
Cells(rowselect, 2) = Me.cbtown.Value
Cells(rowselect, 3) = Me.cbdistrict.Value
Cells(rowselect, 4) = Me.cbstate.Value
Cells(rowselect, 5) = Me.cbfacilityname.Value
Cells(rowselect, 6) = Me.txttypeofsite.Value
Cells(rowselect, 7) = Me.txttypeoffacility.Value
Cells(rowselect, 8) = Me.txtsvetanasiteid.Value
Cells(rowselect, 9) = Me.txtsimsid.Value
Cells(rowselect, 10) = Me.txthivpulseid.Value
Cells(rowselect, 11) = Me.txtdate.Value
Cells(rowselect, 12) = Me.txttimein.Value
Cells(rowselect, 13) = Me.txttimeout.Value
Cells(rowselect, 14) = Me.cbsvdonebyname.Value
Cells(rowselect, 15) = Me.cbsvdonebydesignation.Value
Cells(rowselect, 16) = Me.txtsvothers.Value
Cells(rowselect, 23) = Me.obdoctor.Value
rowselect = rowselect - 1
msg = "Sl No " & rowselect & "  Successfully Updated...Continue?"
Unload Me
ans = MsgBox(msg, vbYesNo, "Update")
If ans = vbYes Then
SVeditForm.Show
Else
Sheets("SVReport").Select
End If
End Sub[/COLOR]



Kindly do the needful


Regards
 
Last edited by a moderator:

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
The only change I made was the one I mentioned in post#11
 
Upvote 0
Just replace the line I showed, with the code I supplied
 
Upvote 0
Then delete this line
Code:
[COLOR=#333333]rowselect = rowselect + 1[/COLOR]
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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