Hi paul, Will you please help me to learn this thing why this code gives error line was highlighted with comment you can search it with question mark in code ,I have alternatives to do this but why that line gives error but not the above ones.
Sub Dictionary_Example() '------------------------------------------------------------- Dim Dic_obj As Object: 'This is a Dictionary object Dim lrow As Long: 'Find out the Last row '------------------------------------------------------------- 'Create a dictionary object Set Dic_obj = CreateObject("scripting.dictionary") 'Clear the dictonary object Dic_obj.RemoveAll With ActiveSheet lrow = .Cells(Rows.Count, 1).End(xlUp).Row For i = 2 To lrow If (Not (Dic_obj.exists(Cells(i, 1).Value))) Then Dic_obj.Add Cells(i, 1).Value, Cells(i, 2).Value Else Dic_obj.Item(Cells(i, 1).Value) = Dic_obj.Item(Cells(i, 1).Value) & "-" & Cells(i, 2).Value End If Next 'This is one dimensional array arr(0,659) 'Note:- Whenever keys copied into array it always one dimensional with lower bound 0 'By using Transpose we will make it single dimensional arr = Dic_obj.keys 'Pasting it on the Sheet2 only unique keys Sheet2.Range("a2").Resize(UBound(arr), 1) = Application.Transpose(arr) 'Find out the Error arr1 = Dic_obj.items 'While running this below line We get an error type mismatch Why?? Because i don't want to run this below loop, _ for retrieving items from those keys. 'Sheet2.Range("b1").Resize(UBound(Demo), 1) = Application.Transpose(Arr1) d = Dic_obj.Count 'Retrieving Items of particular Key For i = 2 To Dic_obj.Count Sheet2.Cells(i, 2).Value = Dic_obj.Item(Sheet2.Cells(i, 1).Value) Next End With End Sub Regards, Mandeep baluja -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/d/optout.