Runtime error "13" ,Type mismatch?

sezuh

Well-known Member
Joined
Nov 19, 2010
Messages
708
hi ,
When i try to run the code below i get, " Run time error 13,Type mismatch" error and when i Debug the code this line Highlighted;
Code:
[J2].Resize(.Count).Value = WorksheetFunction.Transpose(.Keys)

Code:
Sub ezuh1() 
 Application.ScreenUpdating = False


Dim x, y(), i&, j&, k, s, t$, u&, bu As Boolean
x = Range("A1", Cells(Rows.Count, 1).End(xlUp)).Value


With CreateObject("Scripting.Dictionary")
    .CompareMode = 3
    For i = 1 To UBound(x): .Item(x(i, 1)) = 1: Next i


    x = Range("C1", Cells(Rows.Count, 3).End(xlUp)).Value
    ReDim y(1 To UBound(x), 1 To 5)
    For i = 1 To UBound(x)
        t = x(i, 1)
        For Each k In .Keys
            s = Split(k)
            For j = 0 To UBound(s)
                If InStr(t, s(j)) Then bu = True: Exit For
            Next j
            If bu = False Then
                u = u + 1: y(i, u) = k: t = t & " " & k
                .Remove k
            End If
            bu = False
        Next k
        u = 0
    Next i
   [J2].Resize(.Count).Value = WorksheetFunction.Transpose(.Keys)
End With


[d1:H969].Value = y()
Application.ScreenUpdating = True
End Sub

I would Appreciate any help on this please.
Thanks
 

Some videos you may like

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

ranman256

Well-known Member
Joined
Jun 17, 2014
Messages
1,971
It means something cannot assign because of the datatype, Im thinking its "[J2]".
this is not a thing. You cannot make a variable called "[xx]".
Remove the brackets
What is J2? is it a range? Where is the declaration?
 

sezuh

Well-known Member
Joined
Nov 19, 2010
Messages
708
Hi ranman,
thanks for your time,yes its a range ( what left in column "C" after the code run) dumpt in that colum. i tried your suggestion by removing the bracket but still gives me same error and same line highlighted?
thanks again
 

Ragnar1211

Well-known Member
Joined
Jul 10, 2008
Messages
571
Perhaps try:

Range("J2").resize(.count).Value = WorksheetFunction.Transpose(.Keys)
 

Ragnar1211

Well-known Member
Joined
Jul 10, 2008
Messages
571
I'm not sure .keys is giving an array, you may have to read that into an array:

Code:
dim arr(1 to .keys.count, 1 to 1)
for i = 1 to .keys.count
     arr(i,1) = .keys(i)
next i


Range("J2").resize(.count).Value = arr
 

Watch MrExcel Video

Forum statistics

Threads
1,127,530
Messages
5,625,356
Members
416,096
Latest member
forevans

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
Top