views:

228

answers:

1

I have a csv file with userid and manager fields. How can I list all userids that report to a specific manager and its direct reports, drilled down to the last user. Need a quick vbscript.

Thanks.

+2  A: 

Open the CSV file via ADODB.

You need a <final_result> variable (initially empty), and a <managers> variable (initially the ID of the one manager you want to create a list for).

Then write a loop that does:

  1. SELECT DirectReports FROM TextFile WHERE Manager IN ('<managers>')
  2. create a list of the DirectReports IDs from the resulting RecordSet
  3. append that list to the <final_result> variable
  4. assign to the <managers> variable a comma delimited string: "'<id1>','...','<idn>'"
  5. start at #1 unless list is empty

When the loop is through, the final result variable holds all the direct reports.

See - no recursion required. Plain iteration is enough.

Tomalak
+1 for helping but not doing all the work for them.
Tester101