Call '.\xlLib.udf'
; Launch Excel
$oXL=xlInit()
; open file
xlFile($oXL,'myfile.xls',0)
; sort - define the range containing your data, "D1" is the column with
; the manager's name, "A1" contains the user's name - this sorts
; by manager, then by user
xlRangeSort($oXL, 'A1:E6', 'D1',1,'A1',1)
; Return the sorted data in an array - 6 rows of 5 columns in this case
$aData = xlRangeValue($oXL, 'A1:E6')
; Enumerate the data - 2 dimension array
; $aData[0][3] is the manager's name of the first row of data
$Managers = 'mgra','mgrb','mgrc'
For each $Manager in $Managers
For $I = 0 to UBound($aData)
If $aData[$I][3] = $Manager
; Have data for current manager
; write data to manager file
$ = RedirectOutput($Manager + '.csv')
; convert entire row to CSV format - don't forget to include the
; CSV() UDF file.
CSV($aData[$I]) ?
$ = RedirectOutput('')
EndIf
Next
Next
xlQuit($oXL)