Hello,
I just noticed a mistake and thought I found the solution myself already (edits in red), but the same error pops up
I need help with the following code.
Dim pitch_arr As Variant
Dim i As Long
Dim x As Long
x = 1
For i = LBound(screw_data_arr) To UBound(screw_data_arr)
If screw_data_arr(i, 1) = 3 Then
Debug.Print screw_data_arr(i, 2)
pitch_arr(x) = screw_data_arr(i, 2)
x = x + 1
End If
Next i
screw_data_arr is an array that is created in another Sub (Public screw_data_arr As Variant) from a table in one of my worksheets.
It consists of 75 rows and 5 columns.
Column 1 contains different bolt thread sizes, column 2 the respective threads per inch for that thread size (also referred to as "pitch").
So, in my example, if I search for the thread size of 3, it should write all the thread pitch values (4,8,12) for that thread size into the array pitch_arr
Upon executing the code, I get a Type mismatch error inside the If statement.
See the example table below:
Size |
Pitch |
2.5 |
4 |
2.5 |
8 |
2.625 |
12 |
2.75 |
4 |
2.75 |
8 |
2.875 |
12 |
3 |
4 |
3 |
8 |
3 |
12 |
Bookmarks