Run-time error "13" type mismatch

samarrow11

New Member
Joined
Apr 22, 2016
Messages
6
Hello everyone! I am a new guy to excel <acronym title="visual basic for applications" style="border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: rgb(0, 0, 0); cursor: help; color: rgb(51, 51, 51); background-color: rgb(250, 250, 250);">VBA</acronym> and I'm trying to figure out this error.Always get the type mismatch error and don't know why.
the error happened in
z = Application.Workbooks(2).Worksheets(Sheet1).Cells(q, 1).Value * x
code as followed

Sub samyuan1()
Dim z As Single, x As Single, q As Long, y As Long, ufo As Variant, b As Long
For x = 0.1 To 0.9 Step 0.1
For q = 2 To 101
For y = 2 To 101
z = Application.Workbooks(2).Worksheets(Sheet1).Cells(q, 1).Value * x
ufo = Array(Application.WorksheetFunction.NormSInv(0.01), Application.WorksheetFunction.NormSInv(0.02), Application.WorksheetFunction.NormSInv(0.03), Application.WorksheetFunction.NormSInv(0.04), _
Application.WorksheetFunction.NormSInv(0.05), Application.WorksheetFunction.NormSInv(0.06), Application.WorksheetFunction.NormSInv(0.07), Application.WorksheetFunction.NormSInv(0.08), Application.WorksheetFunction.NormSInv(0.09), _
Application.WorksheetFunction.NormSInv(0.1))
If z < ufo(0) Then
b = 1
Else
b = 0
End If
Dim m As Long
For m = 103 To 111
Cells(12, m).Value = b
Next m
Next y
Next q
Next x
End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Missing quotes around the sheet name.

z = Application.Workbooks(2).Worksheets("Sheet1").Cells(q, 1).Value * x
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,584
Messages
6,131,565
Members
449,655
Latest member
Anil K Sonawane

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