#171406 - 2006-12-13 12:57 AM
Re: read cell from excel then validate data
[Re: booey]
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
You made $File1 an array. You should do something like Mart said
For Each $F in $File1
;Do stuff
Next
Here is a modified script. Do not forget to add the DirList() UDF at the end.
If NOT @LOGONMODE Break On Else Break Off EndIf DIM $RC $RC = SetOption("Explicit","On") $RC = SetOption("NoVarsInStrings","On") $RC = SetOption("NoMacrosInStrings","On") $RC = SetOption("WrapAtEOL","On")
DIM $objExcel, $Files, $FilesDir, $File, $File2, $Value, $Values[1,0], $i, $j $FilesDir = "D:\scripts\test\xls\" $File2 = "D:\scripts\test\Workbook2.xls"
$objExcel = CreateObject("Excel.Application") If @ERROR ? "Error creating Excel object" ? "Error " + @ERROR + ": " + @SERROR Quit @ERROR EndIf
$Files = DirList($FilesDir,2) For Each $File In $Files $i = -1 ReDIM $Values[1,0] $RC = $objExcel.Workbooks.Open($File) $Value = $objExcel.Range("C6").Value $objExcel.Application.Quit $RC = $objExcel.Workbooks.Open($File2) While NOT $objExcel.Range("A"+($i+2)).Value = "" $i = $i + 1 ReDIM preserve $Values[1,$i] $Values[0,$i] = $objExcel.Range("A"+($i+1)).Value $Values[1,$i] = $objExcel.Range("B"+($i+1)).Value Loop $objExcel.Application.Quit For $j = 0 To $i Step 1 If $Values[0,$j] = $Value Move $File $Values[1,$j] If @ERROR ? "Error moving file " + $File ? "Error " + @ERROR + ": " + @SERROR EndIf $j = $i EndIf Next
Next
|
|
|
Top
|
|
|
|
#171441 - 2006-12-13 04:46 PM
Re: read cell from excel then validate data
[Re: Witto]
|
booey
Getting the hang of it
Registered: 2005-07-25
Posts: 76
Loc: USA
|
That works great. Thanks for all the help.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2167 anonymous users online.
|
|
|