@Melba23: cauze im new to this forum so I do not know this code tag function. thanx for ur recommend
Here is my code (mayb a little hard to see ). Thiz code used to calculate the Call Setup Time of MS1 & MS2 from the Log File *.FMT
#include <Excel.au3>
Dim $oExcel,$sRangeOrRow, $iColumn, $sField, $sCriteria,$i
$name = InputBox("Input Form","ENTER THE NAME OF UR LOG FILE"&@CRLF&@CRLF&"Ex: Ur logfile is Buu_dien_HCM.fmt. Then juzt enter Buu_dien_HCM in the line below")
$path = "C:Temp"&$name&".fmt"
$vipsave = "C:Temp"&$name
$oExcel = ObjCreate("Excel.Application")
$oExcel.Visible = 1
$oExcel.Workbooks.OpenText($path, _
437, _ ; Origin
1, _ ; StartRow
1, _ ; DataType = x1Delimited
1, _ ; TextQualifier = x1DoubleQuote
False, _ ; ConsecutiveDelimiter
True, _ ; Tab
False, _ ; Semicolon
True, _ ; Comma
False, _ ; Space
False _ ; Other
)
_ExcelBookSaveAs($oExcel, $vipsave, "xls", 0, 1) ; Save file, overwrite existing file if necessary
; #FUNCTION# ====================================================================================================================
; Name...........: _ExcelFilter
; Description ...: Applies a filter to an excel file.
; Syntax.........: _ExcelFilter($oExcel,$sRangeorRow, $iColumn, $sField, $sCriteria)
; Parameters ....: $oExcel - An Excel object opened by a preceding call to _ExcelBookOpen() or _ExcelBookNew()
; $sRangeOrRow - The range in A1 format, or a row number for R1C1 format
; $iColumn - The specified column number for R1C1 format (default = 1)
; $sField- the field no. where filter is to be applied.
; $sCriteria- the criteria for filter is to be applied. For e.g filter by country name "India".
; Return values .: Success - Returns 1
; Failure - Returns 0 and sets @error on errors:
; @error=1 - Specified object does not exist
; @error=2 - Row or column invalid
; @extended=0 - Row invalid
; @extended=1 - Column invalid
; Author ........: Manjish Naik (naikma@gmail.com)
; Modified.......: None as yet
; Remarks .......: None
; Related .......:
; Link ..........;
; Example .......; _ExcelFilter($oExcel,1,2,2,"Amit Ravindra,Patil"), this filters out all entries except the one having "Manager Name" as "Amit Ravindra,Patil".
; The "manager name" is second filter field located at 1 row and 2nd column, hence $sField=2.
; ===============================================================================================================================
Func _ExcelFilter($oExcel, $sRangeOrRow, $iColumn, $sField, $sCriteria)
If Not StringRegExp($sRangeOrRow, "[A-Z,a-z]", 0) Then
If $sRangeOrRow < 1 Then Return SetError(2, 0, 0)
If $iColumn < 1 Then Return SetError(2, 1, 0)
$oExcel.ActiveSheet.Cells($sRangeOrRow, $iColumn).Select
$oExcel.selection.Autofilter($sField, $sCriteria)
Else
$oExcel.ActiveSheet.Range($sRangeOrRow).Select
$oExcel.selection.Autofilter($sField, $sCriteria)
EndIf
EndFunc ;==>_ExcelFilter
_ExcelFilter($oExcel,1,2,2,"MS1")
_ExcelFilter($oExcel,1,6,6,"Call Setup")
Send("{CTRLDOWN}")
Send("a")
Send("c")
Send("{CTRLUP}")
Send("{SHIFTDOWN}")
Send("{F11}")
Send("{SHIFTUP}")
Send("{CTRLDOWN}")
Send("v")
Send("{CTRLUP}")
Sleep(1000)
_ExcelSheetActivate($oExcel,"Sheet1")
$number=_ExcelWriteFormula($oExcel,"=Counta(R2C6:R500C6)",2,16)
$no=_ExcelReadCell($oExcel,2,16)
For $i=1 to $no Step 1
for $j=1 to 10 Step 1
_ExcelWriteFormula($oExcel,"=Left(R"&$i+1&"C8,11)",$i+1,13)
_ExcelWriteFormula($oExcel,"=Mid(R"&$i+1&"C8,14,4)",$i+1,15)
Next
Next
$result = 0
$count1 = 0
For $k=1 to $no Step 1
$setup=_ExcelReadCell($oExcel,$k+1,13)
If $setup = " setup time" Then
$count1 = $count1 + 1
$result=$result + _ExcelReadCell($oExcel,$k+1,15)
EndIf
Next
_ExcelWriteCell($oExcel,$count1,2,16)
$MS1=$result/$count1
Sleep(1000)
_ExcelSheetActivate($oExcel,$name)
_ExcelFilter($oExcel,1,2,2,"MS2")
_ExcelFilter($oExcel,1,6,6,"Call Setup")
Send("{CTRLDOWN}")
Send("a")
Send("c")
Send("{CTRLUP}")
Send("{SHIFTDOWN}")
Send("{F11}")
Send("{SHIFTUP}")
Send("{CTRLDOWN}")
Send("v")
Send("{CTRLUP}")
Sleep(1000)
_ExcelSheetActivate($oExcel,"Sheet2")
$number=_ExcelWriteFormula($oExcel,"=Counta(R2C6:R100C6)",2,16)
$no=_ExcelReadCell($oExcel,2,16)
For $i=1 to $no Step 1
for $j=1 to 10 Step 1
_ExcelWriteFormula($oExcel,"=Left(R"&$i+1&"C8,11)",$i+1,13)
_ExcelWriteFormula($oExcel,"=Mid(R"&$i+1&"C8,14,4)",$i+1,15)
Next
Next
$result = 0
$count2 = 0
For $k=1 to $no Step 1
$setup=_ExcelReadCell($oExcel,$k+1,13)
If $setup = " setup time" Then
$count2 = $count2 + 1
$result=$result + _ExcelReadCell($oExcel,$k+1,15)
EndIf
Next
_ExcelWriteCell($oExcel,$count2,2,16)
$MS2=$result/$count2
$round_MS1 = Round($MS1,2)
$round_MS2 = Round($MS2,2)
_ExcelSheetActivate($oExcel,$name)
Send("{ESC}")
;_ExcelBookClose($oExcel,1,0) ;Close & Save
If ($count1 <> 0) And ($count2 <> 0) Then
MsgBox(0,"Call Setup Time (ms): "&$name,"MS1 = "&$round_MS1&@CRLF&"MS2 = "&$round_MS2)
ElseIf ($count1 = 0) & ($count2 <> 0) Then
MsgBox(0,"Call Setup Time (ms): "&$name,"MS1 = Unknown"&@CRLF&"MS2 = "&$round_MS2)
Else
MsgBox(0,"Call Setup Time (ms): "&$name,"MS1 = "&$round_MS1&@CRLF&"MS2 = Unknown")
EndIf