-1

スクリプトのパラメーターを設定できるように、(Excel ドキュメント内の) 行数を自動的に決定するにはどうすればよいですか?

#include <Excel Rewrite.au3>

Global $i = 1
Global $selector = '"of","restaurant","courtyard","licenced","landscapes","travel","specialist","testing","relay","imaging","environmental","associates"'
Global $sFormula = "=IF(OR(ISNUMBER(search("" ""&{" & $selector & "}&"" "","" ""&b" & $i & "&"" ""))),""YES"",""NO"")"

Global Const $xlCellTypeVisible = 12 ; All visible cells
Global $aData = $sFormula
Global $oExcel = _Excel_Open() ; Connect to Excel or open a new instance
Global $oWorkbook = _Excel_BookNew($oExcel) ; Create a new workbook

For $i = 0 To 100 step 1
Next

_Excel_RangeWrite($oWorkbook, Default, $aData, "A1:A100");
MsgBox(0, "RangeWrite Data", @error)
_Excel_FilterSet($oWorkbook, Default, $oWorkbook.Activesheet.UsedRange, 1, "NO") ; Only display even numbers
MsgBox(0, "FilterSet", @error)
Global $oRange = $oWorkbook.Activesheet.UsedRange.SpecialCells($xlCellTypeVisible) ; Only select visible rows
MsgBox(0, "Visible cells", @error)
$oRange.EntireRow.Delete ; delete visible rows
4

3 に答える 3

0

例(Excel.au3を使用しない場合)

; Create new Excel file with one sheet 
Local $oExcel = ObjCreate("Excel.Application")
With $oExcel
    .SheetsInNewWorkbook = 1
    .Visible = 1
    .WorkBooks.Add
    .ActiveWorkbook.Worksheets(1).Name = "Foo"
    .ActiveWorkbook.Worksheets(1).Cells(1,1) = "IBICF !!!"
EndWith

; Write some data in sheet "Foo"
Local $array_1[5] = ["c1","c2","c3","c4","c5"]
Local $array_2[5] = ["val11","val12","val13","val14","val15"]
Local $array_3[5] = ["val21","val22","val23","val24","val25"]
Local $array_4[5] = ["val31","val32","val33","val34","val35"]
For $i = 0 To Ubound($array_1) - 1
    $oExcel.Activesheet.Cells(1,($i+1)).Value = $array_1[$i]
    $oExcel.Activesheet.Cells(2,($i+1)).Value = $array_2[$i]
    $oExcel.Activesheet.Cells(3,($i+1)).Value = $array_3[$i]
    $oExcel.Activesheet.Cells(4,($i+1)).Value = $array_4[$i]
Next

; Get the count number columns and rows use in this sheet
Local $number_cols = $oExcel.ActiveSheet.UsedRange.Columns.Count
Local $number_rows = $oExcel.ActiveSheet.UsedRange.Rows.Count

http://www.autoitscript.fr/forum/viewtopic.php?t=3272&f=11に関する詳細情報 (フランス語)

于 2014-10-13T12:39:18.337 に答える
0

Doループの出口がありません。

DoループはUntilnotで終了する必要がありendます。

Do
    statements
    ...
Until <expression>

あなたのwhileループはで終わるべきだと思いますWEnd

While <expression>
    statements
    ...
WEnd

一緒にこのようなもの:

Do
  Local $i, 100, step = 1
  if not ( $i and 100 and 1) then error() EndFunc

  While (100>0 and $i<=100) or (100<=0 and $i>=100 do
    _ExcelWriteFormula($oExcel, $sFormula, $sRangeOrRow, $iColumn = $i)
    $i = $i + 1
  WEnd
Until $i = 100 'What ever your condition is to exit the do loop
于 2013-10-16T21:20:25.520 に答える