Type Mismatch

johnsonk

Board Regular
Joined
Feb 4, 2019
Messages
172
Hi,
Can anyone help with the code below I keep getting a type mismatch error on the line highlighted in red and I don't know why.

Rich (BB code):
Private Sub textbox17_Change()
Dim m As Variant
With ThisWorkbook.Worksheets("Data")
m = WorksheetFunction.Match(TextBox1.Text, .Columns(1), 0)
If ComboBox1.Value = "OUT" Then
With .Cells(CLng(m), "C")
.Value = .Value + ComboBox5.Value
End With
ElseIf ComboBox1.Value = "IN" Then
With .Cells(CLng(m), "C")
.Value = .Value - ComboBox5.Value
  If ComboBox1.Value = "OUT" Then
With .Cells(CLng(m), "D")
.Value = .Value + ComboBox7.Value
End With
ElseIf ComboBox1.Value = "IN" Then
With .Cells(CLng(m), "D")
 .Value = .Value - ComboBox7.Value
End With
End If
End With
End If
End With
End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Most likely whatever is in Combobox7 can't be coerced to a number by VBA.
 
Upvote 0
Before the line that causes the error, add:

Code:
msgbox "Cell value: " & .value
msgbox combobox7.value

and tell us what messages you see.
 
Upvote 0
Hi, Below is the message I get, when I click ok on the first message I then get another

1603110957814.png
1603110983735.png
 
Upvote 0
That's the problem then. Neither of those are numbers, so you can't subtract one from the other.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,878
Messages
6,122,062
Members
449,064
Latest member
scottdog129

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