title: Error: Object Required: '[undefined]' for a dictionary object
body: <p><strong><em>Requirement:</em></strong></p>
  
  <p>Please read the following template:</p>
  
  <pre><code>PID     Status      LPID
  
  10       Closed      25
  11       Open        25
  31       Open        31
  25       Closed      25
  54       Open        31
  17       Open        17
  20       Closed      31
  88       closed      77
  77       closed      77
  101      Closed      66
  102      closed      220
  </code></pre>
  
  <p>Now when PID!= LPID, that PID is defined as CPID(Child Process ID),Otherwise it is a PPID(Parent process ID)</p>
  
  <p><strong>Update</strong> There can be some entries say 101 and 102,which are child ,but their Parents don't have a thier own etires thus 66,220 shouldn't come to the output result as <code>66 Parent</code> and <code>220 Parent</code> no such output should be there.</p>
  
  <p>Now I am looking for a code which will tell which is parent and Which is child- means marking them in another sheet.At the Same time i want to list down all CPID,with PPID in the same row,If any PPID has child Processes themselves. Output would be look like below</p>
  
  <pre><code>PID   Type Of Process?    Child1   Child1   Child3 .... ChildN
  10       Child
  11       Child
  31       Parent             54      20
  25       Parent             10      11
  54       Child
  17       Parent
  20       Child
  88       Child
  77       Parent             88
  </code></pre>
  
  <p>I have written a code using VBScript,but with the actual sheet it is too slow. For 2500 data it is taking close to 1 hour.So I Want a more faster process than my one.</p>
  
  <p>I wrote the below code to meet some requirement: But getting an error which is not understandable.</p>
  
  <p>Can you help me here? I tried in both way the syntax <code>Add</code> or <code>=</code>- nothing helped.</p>
  
  <p>Option Explicit</p>
  
  <pre><code>Class cP
   Public m_sRel
   Public m_dicC
      Private Sub Class_Initialize()
       m_sRel     = "Child"
       Set m_dicC = CreateObject("Scripting.Dictionary")
      End Sub
      Public Function show()
       show = m_sRel &amp; " " &amp; Join(m_dicC.Keys)
      End Function
  End Class
  
  Dim objSheet1,objSheet2,TotalRows,TotalcolCopy,strPathExcel1
  Dim oXls  : Set oXls = CreateObject("Excel.Application")
  Dim dicP  : Set dicP = CreateObject("Scripting.Dictionary")
  Dim nRow,nP
  
  strPathExcel1 = "D:\Finalscripts\test.xlsx"
  oXls.Workbooks.open strPathExcel1
  'oXls.Workbooks.Open(oFs.GetAbsolutePathName("Test.xlsx"))
  Set objSheet1 = oXls.ActiveWorkbook.Worksheets("A")
  Set objSheet2 = oXls.ActiveWorkbook.Worksheets("B")
  
  
  TotalRows=oXls.Application.WorksheetFunction.CountA(objSheet1.Columns(1)) - 3
  TotalcolCopy=oXls.Application.WorksheetFunction.Match("ABC", objSheet1.Rows(3), 0)
  
  objSheet1.Range(objSheet1.Cells(4,1),objSheet1.Cells(TotalRows,TotalcolCopy)).Copy(objSheet2.Range("A1"))
  objSheet2.Range(objSheet2.Cells(1,2),objSheet2.Cells(TotalRows,TotalcolCopy-1)).Delete(-4159)
  'Dim aData : aData=objSheet2.Cells.SpecialCells(12)'xlCellTypeVisible
  TotalRows = oXls.Application.WorksheetFunction.CountA(objSheet2.Columns(1))
  Dim aData : aData = objSheet2.Range("A1:B"&amp;TotalRows)
  
  'MsgBox(LBound(aData, 1)&amp;"And"&amp;UBound(aData, 1))
  
     For nRow = LBound(aData, 1) To UBound(aData, 1)
  
       Set dicP(aData(nRow, 1)) = New cP
  
     Next
  
     For nRow = LBound(aData, 1) To UBound(aData, 1)
  
          If aData(nRow, 1) = aData(nRow, 2) Then
             dicP(aData(nRow, 1)).m_sRel = "Parent"
          Else
             dicP(aData(nRow, 2)).m_dicC.Add   aData(nRow, 1), 0         '(aData(nRow, 1)) = 0
          End If
  
     Next
  
      objSheet2.Cells.ClearContents'To clear all the previous contenets of the sheet#2
  
      nRow=1
      For Each nP In dicP.Keys()
  
      objSheet2.Cells(nRow,1).Value=nP
      objSheet2.Cells(nRow,2).Value=dicP(nP).m_sRel
  
         'WScript.Echo nP, dicP(nP).show()
  
  
      nRow=nRow+1  
      Next
  </code></pre>
  
  <p><em>Error:</em> Object Required: '[undefined]' at the line <code>dicP(aData(nRow, 2)).m_dicC.Add   aData(nRow, 1), 0         '(aData(nRow, 1)) = 0</code></p>
  
  <p><strong>EDIT:</strong> To get the child list,I wrote the below code with the above:</p>
  
  <pre><code>       For Each nP In dicP.Keys()
  
      objSheet2.Cells(nRow,1).Value=nP
      objSheet2.Cells(nRow,2).Value=dicP(nP).m_sRel
      objSheet2.Range("C"&amp;nRow).Value=dicP(nP).m_dicC.Keys
  
         'WScript.Echo nP, dicP(nP).show()
  
  
      nRow=nRow+1  
         Next
  </code></pre>
  
  <p>But Desired output is not coming,Can you suggest here?</p>