iceberg Posted August 17, 2008 Share Posted August 17, 2008 hi guys, i would to be able to achieve the following: read the excel spreadsheet in the following manner:- B2, B3, B4, B5, B6, C2, C3, C4, C5, C6, etc...... the problem is that the row numbers keep on increasing. can someone pls assit me here...? i got the following code to start off though it is not working.... $LastRow = $oExcel.ActiveSheet.UsedRange.Rows.Count; eg 10 For $i = 2 To $col $sCellValue = _ExcelReadCell($oExcel, $LastRow, $i) MsgBox(0, "", $sCellValue) $LastRow = $LastRow - 1 Next mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 17, 2008 Share Posted August 17, 2008 hi guys, i would to be able to achieve the following: read the excel spreadsheet in the following manner:- B2, B3, B4, B5, B6, C2, C3, C4, C5, C6, etc...... the problem is that the row numbers keep on increasing. can someone pls assit me here...? i got the following code to start off though it is not working.... $LastRow = $oExcel.ActiveSheet.UsedRange.Rows.Count; eg 10 For $i = 2 To $col $sCellValue = _ExcelReadCell($oExcel, $LastRow, $i) MsgBox(0, "", $sCellValue) $LastRow = $LastRow - 1 Next If you want to read them one at a time, you just have two nested For/Next loops (and you appear to want to walk the rows backwards): $LastRow = $oExcel.ActiveSheet.UsedRange.Rows.Count; eg 10 ; For rows = last row used to 2 (backwards) For $iRow = $LastRow To 2 Step -1 ; For columns B and C For $iCol = 2 To 3; Columns B and C $sCellValue = _ExcelReadCell($oExcel, $iRow, $iCol) MsgBox(0, "", "Row " & $iRow & ", Col " & $iCol & " = " & $sCellValue) Next Next You could also read them all with one function: #include <Excel.au3> #include <Array.au3> ; ... ; Read from row 2 to last row, columns B and C $avArray = _ExcelReadSheetToArray($oExcel, 2, 2, 0, 2) _ArrayDisplay($avArray, "Excel Data") Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
iceberg Posted August 18, 2008 Author Share Posted August 18, 2008 thanks for helping me PsaltyDS. so far I have come up with this. not sure if my method is the best way to approach this problem. what I had hoped to accomplish was this : this script would be run hourly. so for every run, the script has to read the excel lines based on the INI file. meaning if it is run at 11:00 and the last line was 10, then when it is run again at 12:00 it should start reading from line 11 till the current last line. i need this to be done for every other used columns as well. i tried my best i guess and obviously i screwed it up BIG time....appreciate your help once again. expandcollapse popup#include <ExcelCOM_UDF.au3> #include <array.au3> #include <string.au3> Global $col, $oExcel, $sCellValue $sFilePath1 = @ScriptDir & "\Test.csv" $oExcel = _ExcelBookopen(@ScriptDir & "\test.csv", 0, False) $iErrorSav = @error If IsObj($oExcel) = 0 Or $iErrorSav <> 0 Then MsgBox(16, "Error opening Excel book!", "$oExcel = " & $oExcel & " @error = " & $iErrorSav) Exit EndIf $array = _ExcelSheetUsedRangeGet($oExcel, 1) ;MsgBox(0, "last cell", $array[0]) $eNum = _StripNonNum($array[0]) $eAlpha = _StripNonAlpha($array[0]) If $eAlpha = "A" Then $col = 1 If $eAlpha = "B" Then $col = 2 If $eAlpha = "C" Then $col = 3 If $eAlpha = "D" Then $col = 4 If $eAlpha = "E" Then $col = 5 If $eAlpha = "F" Then $col = 6 If $eAlpha = "G" Then $col = 7 If $eAlpha = "H" Then $col = 8 If $eAlpha = "I" Then $col = 9 If $eAlpha = "J" Then $col = 10 If $eAlpha = "K" Then $col = 11 If $eAlpha = "L" Then $col = 12 If $eAlpha = "M" Then $col = 13 If $eAlpha = "N" Then $col = 14 If $eAlpha = "O" Then $col = 15 If $eAlpha = "P" Then $col = 16 If $eAlpha = "Q" Then $col = 17 If $eAlpha = "R" Then $col = 18 If $eAlpha = "S" Then $col = 19 If $eAlpha = "T" Then $col = 20 If $eAlpha = "U" Then $col = 21 If $eAlpha = "V" Then $col = 22 If $eAlpha = "W" Then $col = 23 If $eAlpha = "X" Then $col = 24 If $eAlpha = "Y" Then $col = 25 If $eAlpha = "Z" Then $col = 26 If $eAlpha = "AA" Then $col = 27 If $eAlpha = "AB" Then $col = 28 If $eAlpha = "AC" Then $col = 29 If $eAlpha = "AD" Then $col = 30 If $eAlpha = "AE" Then $col = 31 If $eAlpha = "AF" Then $col = 32 If $eAlpha = "AG" Then $col = 33 If $eAlpha = "AH" Then $col = 34 If $eAlpha = "AI" Then $col = 35 If $eAlpha = "AJ" Then $col = 36 If $eAlpha = "AK" Then $col = 37 If $eAlpha = "AL" Then $col = 38 If $eAlpha = "AM" Then $col = 39 If $eAlpha = "AN" Then $col = 40 If $eAlpha = "AO" Then $col = 41 If $eAlpha = "AP" Then $col = 42 If $eAlpha = "AQ" Then $col = 43 If $eAlpha = "AR" Then $col = 44 If $eAlpha = "AS" Then $col = 45 If $eAlpha = "AT" Then $col = 46 If $eAlpha = "AU" Then $col = 47 If $eAlpha = "AV" Then $col = 48 If $eAlpha = "AW" Then $col = 49 If $eAlpha = "AX" Then $col = 50 If $eAlpha = "AY" Then $col = 51 If $eAlpha = "AZ" Then $col = 52 If $eAlpha = "BA" Then $col = 53 If $eAlpha = "BB" Then $col = 54 If $eAlpha = "BC" Then $col = 55 If $eAlpha = "BD" Then $col = 56 If $eAlpha = "BE" Then $col = 57 If $eAlpha = "BF" Then $col = 58 If $eAlpha = "BG" Then $col = 59 If $eAlpha = "BH" Then $col = 60 If $eAlpha = "BI" Then $col = 61 If $eAlpha = "BJ" Then $col = 62 If $eAlpha = "BK" Then $col = 63 If $eAlpha = "BL" Then $col = 64 If $eAlpha = "BM" Then $col = 65 If $eAlpha = "BN" Then $col = 66 If $eAlpha = "BO" Then $col = 67 If $eAlpha = "BP" Then $col = 68 If $eAlpha = "BQ" Then $col = 69 If $eAlpha = "BR" Then $col = 70 If $eAlpha = "BS" Then $col = 71 If $eAlpha = "BT" Then $col = 72 If $eAlpha = "BU" Then $col = 73 If $eAlpha = "BV" Then $col = 74 If $eAlpha = "BW" Then $col = 75 If $eAlpha = "BX" Then $col = 76 If $eAlpha = "BY" Then $col = 77 If $eAlpha = "BZ" Then $col = 78 If $eAlpha = "CA" Then $col = 79 If $eAlpha = "CB" Then $col = 80 If $eAlpha = "CC" Then $col = 81 If $eAlpha = "CD" Then $col = 82 If $eAlpha = "CE" Then $col = 83 If $eAlpha = "CF" Then $col = 84 If $eAlpha = "CG" Then $col = 85 If $eAlpha = "CH" Then $col = 86 If $eAlpha = "CI" Then $col = 87 If $eAlpha = "CJ" Then $col = 88 If $eAlpha = "CK" Then $col = 89 If $eAlpha = "CL" Then $col = 90 If $eAlpha = "CM" Then $col = 91 If $eAlpha = "CN" Then $col = 92 If $eAlpha = "CO" Then $col = 93 If $eAlpha = "CP" Then $col = 94 If $eAlpha = "CQ" Then $col = 95 If $eAlpha = "CR" Then $col = 96 If $eAlpha = "CS" Then $col = 97 If $eAlpha = "CT" Then $col = 98 If $eAlpha = "CU" Then $col = 99 If $eAlpha = "CV" Then $col = 100 If $eAlpha = "CW" Then $col = 101 If $eAlpha = "CX" Then $col = 102 If $eAlpha = "CY" Then $col = 103 If $eAlpha = "CZ" Then $col = 104 If $eAlpha = "DA" Then $col = 105 If $eAlpha = "DB" Then $col = 106 If $eAlpha = "DC" Then $col = 107 If $eAlpha = "DD" Then $col = 108 If $eAlpha = "DE" Then $col = 109 If $eAlpha = "DF" Then $col = 110 If $eAlpha = "DG" Then $col = 111 If $eAlpha = "DH" Then $col = 112 If $eAlpha = "DI" Then $col = 113 If $eAlpha = "DJ" Then $col = 114 If $eAlpha = "DK" Then $col = 115 If $eAlpha = "DL" Then $col = 116 If $eAlpha = "DM" Then $col = 117 If $eAlpha = "DN" Then $col = 118 If $eAlpha = "DO" Then $col = 119 If $eAlpha = "DP" Then $col = 120 If $eAlpha = "DQ" Then $col = 121 If $eAlpha = "DR" Then $col = 122 If $eAlpha = "DS" Then $col = 123 If $eAlpha = "DT" Then $col = 124 If $eAlpha = "DU" Then $col = 125 If $eAlpha = "DV" Then $col = 126 If $eAlpha = "DW" Then $col = 127 If $eAlpha = "DX" Then $col = 128 If $eAlpha = "DY" Then $col = 129 If $eAlpha = "DZ" Then $col = 130 If $eAlpha = "EA" Then $col = 131 If $eAlpha = "EB" Then $col = 132 If $eAlpha = "EC" Then $col = 133 If $eAlpha = "ED" Then $col = 134 If $eAlpha = "EE" Then $col = 135 If $eAlpha = "EF" Then $col = 136 If $eAlpha = "EG" Then $col = 137 If $eAlpha = "EH" Then $col = 138 If $eAlpha = "EI" Then $col = 139 If $eAlpha = "EJ" Then $col = 140 If $eAlpha = "EK" Then $col = 141 If $eAlpha = "EL" Then $col = 142 If $eAlpha = "EM" Then $col = 143 If $eAlpha = "EN" Then $col = 144 If $eAlpha = "EO" Then $col = 145 If $eAlpha = "EP" Then $col = 146 If $eAlpha = "EQ" Then $col = 147 If $eAlpha = "ER" Then $col = 148 If $eAlpha = "ES" Then $col = 149 If $eAlpha = "ET" Then $col = 150 If $eAlpha = "EU" Then $col = 151 If $eAlpha = "EV" Then $col = 152 If $eAlpha = "EW" Then $col = 153 If $eAlpha = "EX" Then $col = 154 If $eAlpha = "EY" Then $col = 155 If $eAlpha = "EZ" Then $col = 156 If $eAlpha = "FA" Then $col = 157 If $eAlpha = "FB" Then $col = 158 If $eAlpha = "FC" Then $col = 159 If $eAlpha = "FD" Then $col = 160 If $eAlpha = "FE" Then $col = 161 If $eAlpha = "FF" Then $col = 162 If $eAlpha = "FG" Then $col = 163 If $eAlpha = "FH" Then $col = 164 If $eAlpha = "FI" Then $col = 165 If $eAlpha = "FJ" Then $col = 166 If $eAlpha = "FK" Then $col = 167 If $eAlpha = "FL" Then $col = 168 If $eAlpha = "FM" Then $col = 169 If $eAlpha = "FN" Then $col = 170 If $eAlpha = "FO" Then $col = 171 If $eAlpha = "FP" Then $col = 172 If $eAlpha = "FQ" Then $col = 173 If $eAlpha = "FR" Then $col = 174 If $eAlpha = "FS" Then $col = 175 If $eAlpha = "FT" Then $col = 176 If $eAlpha = "FU" Then $col = 177 If $eAlpha = "FV" Then $col = 178 If $eAlpha = "FW" Then $col = 179 If $eAlpha = "FX" Then $col = 180 If $eAlpha = "FY" Then $col = 181 If $eAlpha = "FZ" Then $col = 182 If $eAlpha = "GA" Then $col = 183 If $eAlpha = "GB" Then $col = 184 If $eAlpha = "GC" Then $col = 185 If $eAlpha = "GD" Then $col = 186 If $eAlpha = "GE" Then $col = 187 If $eAlpha = "GF" Then $col = 188 If $eAlpha = "GG" Then $col = 189 If $eAlpha = "GH" Then $col = 190 If $eAlpha = "GI" Then $col = 191 If $eAlpha = "GJ" Then $col = 192 If $eAlpha = "GK" Then $col = 193 If $eAlpha = "GL" Then $col = 194 If $eAlpha = "GM" Then $col = 195 If $eAlpha = "GN" Then $col = 196 If $eAlpha = "GO" Then $col = 197 If $eAlpha = "GP" Then $col = 198 If $eAlpha = "GQ" Then $col = 199 If $eAlpha = "GR" Then $col = 200 For $c = 2 To $col $servernm = _ExcelReadCell($oExcel, 1, $col) $header = _StringBetween($servernm, "\\", "\") MsgBox(0, "", $header) IniWrite(@ScriptDir & "\settings.ini", $header, "LastReading", "2") $LastRow = $oExcel.ActiveSheet.UsedRange.Rows.Count $IniRow = IniRead(@ScriptDir & "\settings.ini", $header, "LastReading", "") For $iRow = $IniRow To $LastRow Step +1 For $iCol = 2 To $col $sCellValue = _ExcelReadCell($oExcel, $iRow, $iCol) ;MsgBox(0, "", "Row " & $iRow & ", Col " & $iCol & " = " & $header) Next Next IniWrite(@ScriptDir & "\settings.ini", $header, "LastReading", $LastRow) Next MsgBox(0, "", "Done.") _ExcelBookClose($oExcel, 0, 0) Exit Func _StripNonAlpha($A_Val2) If $A_Val2 <> "" Then $CharInQuest2 = StringLeft($A_Val2, 1) If StringIsAlpha($CharInQuest2) Or ($CharInQuest2 = ".") Then Return $CharInQuest2 & _StripNonAlpha(StringTrimLeft($A_Val2, 1)) Else Return _StripNonAlpha(StringTrimLeft($A_Val2, 1)) EndIf Else Return "" EndIf EndFunc ;==>_StripNonAlpha Func _StripNonNum($A_Val1) If $A_Val1 <> "" Then $CharInQuest = StringLeft($A_Val1, 1) If StringIsDigit($CharInQuest) Or ($CharInQuest = ".") Then Return $CharInQuest & _StripNonNum(StringTrimLeft($A_Val1, 1)) Else Return _StripNonNum(StringTrimLeft($A_Val1, 1)) EndIf Else Return "" EndIf EndFunc ;==>_StripNonNum and also would apprecita if someone could enlighten me as to how I can tackle this script in a easier way...thanks. mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 18, 2008 Share Posted August 18, 2008 thanks for helping me PsaltyDS. so far I have come up with this. not sure if my method is the best way to approach this problem. what I had hoped to accomplish was this : this script would be run hourly. so for every run, the script has to read the excel lines based on the INI file. meaning if it is run at 11:00 and the last line was 10, then when it is run again at 12:00 it should start reading from line 11 till the current last line. i need this to be done for every other used columns as well. i tried my best i guess and obviously i screwed it up BIG time....appreciate your help once again. expandcollapse popup#include <ExcelCOM_UDF.au3> #include <array.au3> #include <string.au3> Global $col, $oExcel, $sCellValue $sFilePath1 = @ScriptDir & "\Test.csv" $oExcel = _ExcelBookopen(@ScriptDir & "\test.csv", 0, False) $iErrorSav = @error If IsObj($oExcel) = 0 Or $iErrorSav <> 0 Then MsgBox(16, "Error opening Excel book!", "$oExcel = " & $oExcel & " @error = " & $iErrorSav) Exit EndIf $array = _ExcelSheetUsedRangeGet($oExcel, 1) ;MsgBox(0, "last cell", $array[0]) $eNum = _StripNonNum($array[0]) $eAlpha = _StripNonAlpha($array[0]) If $eAlpha = "A" Then $col = 1 ; ...clipped If $eAlpha = "GR" Then $col = 200 For $c = 2 To $col $servernm = _ExcelReadCell($oExcel, 1, $col) $header = _StringBetween($servernm, "\\", "\") MsgBox(0, "", $header) IniWrite(@ScriptDir & "\settings.ini", $header, "LastReading", "2") $LastRow = $oExcel.ActiveSheet.UsedRange.Rows.Count $IniRow = IniRead(@ScriptDir & "\settings.ini", $header, "LastReading", "") For $iRow = $IniRow To $LastRow Step +1 For $iCol = 2 To $col $sCellValue = _ExcelReadCell($oExcel, $iRow, $iCol) ;MsgBox(0, "", "Row " & $iRow & ", Col " & $iCol & " = " & $header) Next Next IniWrite(@ScriptDir & "\settings.ini", $header, "LastReading", $LastRow) Next MsgBox(0, "", "Done.") _ExcelBookClose($oExcel, 0, 0) Exit Func _StripNonAlpha($A_Val2) If $A_Val2 <> "" Then $CharInQuest2 = StringLeft($A_Val2, 1) If StringIsAlpha($CharInQuest2) Or ($CharInQuest2 = ".") Then Return $CharInQuest2 & _StripNonAlpha(StringTrimLeft($A_Val2, 1)) Else Return _StripNonAlpha(StringTrimLeft($A_Val2, 1)) EndIf Else Return "" EndIf EndFunc ;==>_StripNonAlpha Func _StripNonNum($A_Val1) If $A_Val1 <> "" Then $CharInQuest = StringLeft($A_Val1, 1) If StringIsDigit($CharInQuest) Or ($CharInQuest = ".") Then Return $CharInQuest & _StripNonNum(StringTrimLeft($A_Val1, 1)) Else Return _StripNonNum(StringTrimLeft($A_Val1, 1)) EndIf Else Return "" EndIf EndFunc ;==>_StripNonNum and also would apprecita if someone could enlighten me as to how I can tackle this script in a easier way...thanks. Egad! Any time you find yourself repeating something like that you know you are off the tracks! To begin with, there is no reason for that conversion. The Funcion _ExcelSheetUsedRangeGet() returns an array. You don't have to use the A1 format in [0] and convert, the last column is already in [2] and the last row in [3]. So simply using $array[2] avoids that entire process. Even if you had to perform that conversion, You could just do the math. 'A' represents column 1, and ASC('A') = 65. So you can take a letter and convert it to colums by just $iCol = ASC($sLetter) - 64. Multiple letters just means string split it first and handle the letters in a For/Next loop. About 5 to 10 lines of code, tops. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
iceberg Posted August 18, 2008 Author Share Posted August 18, 2008 ok wow...!!! thanks alot....from 100s of lines of codes...to just a few lines...you hv really indeed made me do a lot of thinking. actually this is my first attempt at excel. i hv come up with this simplified version...thanks to you PsaltyDS. hope i am on the right track now.... expandcollapse popup#include <ExcelCOM_UDF.au3> #include <array.au3> #include <string.au3> #include <date.au3> Global $LastRow = 0 Global $col, $oExcel, $sCellValue, $array Global $inifile = @ScriptDir & "\settings.ini" If IniRead($inifile, "config", "date", "date") <> @YEAR & @MON & @MDAY Then $oExcel = "C:\PerfLogs\CPU_" & @YEAR & @MON & @MDAY & ".csv" $ID = IniWrite($inifile, "config", "date", @YEAR & @MON & @MDAY) EndIf $xFiles = _ExcelBookopen("C:\PerfLogs\CPU_" & (IniRead($inifile, "config", "date", "date")) & ".csv", 0, False) $iErrorSav = @error If IsObj($xFiles) = 0 Or $iErrorSav <> 0 Then MsgBox(16, "Error opening Excel book!", "$oExcel = " & $xFiles & " @error = " & $iErrorSav) Exit EndIf $array = _ExcelSheetUsedRangeGet($xFiles, 1) For $i = 2 To $array[2] $header = _StringBetween(_ExcelReadCell($xFiles, 1, $i), "\\", "\") IniWrite($inifile, $header[0], "Counter", "0") $NowRow = $array[3];current last row number $IniRow = IniRead($inifile, "config", "LastRow", "");previous last row number For $j = $IniRow To $NowRow Step +1 $sCellValue = _ExcelReadCell($xFiles, $j, $array[2]) MsgBox(0, "", "Row " & $j & ", Col " & $array[2] & " = " & $header[0]) Next Next _ExcelBookClose($xFiles, 0, 0) Exit is there anything else i can improve on? thanks once again. mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
iceberg Posted August 18, 2008 Author Share Posted August 18, 2008 (edited) ok just found out that the for/next loop function is not producing the results i expected. would appreciate some kind help me. i even tried with Do/Until.....still not working i am obviously missing something here.... For $i = 2 To $array[2] $header = _StringBetween(_ExcelReadCell($xFiles, 1, $i), "\\", "\") IniWrite($inifile, $header[0], "Counter", "0") $NowRow = $array[3] $IniRow = IniRead($inifile, "cpu", "lastrow", "") $j = $IniRow Do $j = $j + 1 $sCellValue = _ExcelReadCell($xFiles, $j, $array[2]) MsgBox(0, "", $sCellValue) Until $j = $NowRow Next thanks. Edited August 18, 2008 by iceberg mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 18, 2008 Share Posted August 18, 2008 ok just found out that the for/next loop function is not producing the results i expected. would appreciate some kind help me. i even tried with Do/Until.....still not working i am obviously missing something here.... For $i = 2 To $array[2] $header = _StringBetween(_ExcelReadCell($xFiles, 1, $i), "\\", "\") IniWrite($inifile, $header[0], "Counter", "0") $NowRow = $array[3] $IniRow = IniRead($inifile, "cpu", "lastrow", "") $j = $IniRow Do $j = $j + 1 $sCellValue = _ExcelReadCell($xFiles, $j, $array[2]) MsgBox(0, "", $sCellValue) Until $j = $NowRow Next thanks. I can only guess what that's doing that isn't as intended. What happens when you run it? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
iceberg Posted August 19, 2008 Author Share Posted August 19, 2008 hi, the script runs ok without any errors. but only for this problem let's say i have 4 cols and 6 rows b1, c1 and d1 will be the col headers so it is supposed to at least msgbox to me in the following order/pattern readcells = b2 & b1 readcells = b3 & b1 readcells = b4 & b1 readcells = b5 & b1 readcells = b6 & b1 readcells = b7 & b1 and then proceed to readcells = c2 & c1 readcells = c3 & c1 readcells = c4 & c1 readcells = c5 & c1 readcells = c6 & c1 readcells = c7 & c1 and so on.... what happens now is that it only reads one particuar cols 3 times. i don't know what I am doing wrong or missing out..... For $i = 2 To $array[2];i think the problem is here cos it just doesn't "jump" to the other cols $header = _StringBetween(_ExcelReadCell($xFiles, 1, $i), "\\", "\") IniWrite($inifile, $header[0], "Counter", "0") $NowRow = $array[3] $IniRow = IniRead($inifile, "cpu", "lastrow", "") $j = $IniRow Do $j = $j + 1 $sCellValue = _ExcelReadCell($xFiles, $j, $array[2]) MsgBox(0, "", $sCellValue) Until $j = $NowRow Next mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 19, 2008 Share Posted August 19, 2008 hi, the script runs ok without any errors. but only for this problem let's say i have 4 cols and 6 rows b1, c1 and d1 will be the col headers so it is supposed to at least msgbox to me in the following order/pattern readcells = b2 & b1 readcells = b3 & b1 readcells = b4 & b1 readcells = b5 & b1 readcells = b6 & b1 readcells = b7 & b1 and then proceed to readcells = c2 & c1 readcells = c3 & c1 readcells = c4 & c1 readcells = c5 & c1 readcells = c6 & c1 readcells = c7 & c1 and so on.... what happens now is that it only reads one particuar cols 3 times. i don't know what I am doing wrong or missing out..... For $i = 2 To $array[2];i think the problem is here cos it just doesn't "jump" to the other cols $header = _StringBetween(_ExcelReadCell($xFiles, 1, $i), "\\", "\") IniWrite($inifile, $header[0], "Counter", "0") $NowRow = $array[3] $IniRow = IniRead($inifile, "cpu", "lastrow", "") $j = $IniRow Do $j = $j + 1 $sCellValue = _ExcelReadCell($xFiles, $j, $array[2]) MsgBox(0, "", $sCellValue) Until $j = $NowRow Next The _ExcelReadCell() uses $j for the row, and $array[2] for the column each time. I see something changing $j, but it looks to me like $array[2] is the used range last column, which doesn't change. Did you mean to read only the last column over and over? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
iceberg Posted August 19, 2008 Author Share Posted August 19, 2008 oops....is tat so? no it is not meant to be like tat. it is not supposed to read the last column over and over again. no wonder its displaying the last column 3 times. it just needs to display each column once only. having identified my silly mistake, how to I rectify it? I am clueless. thanks again PsaltyDS! mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 19, 2008 Share Posted August 19, 2008 (edited) oops....is tat so? no it is not meant to be like tat. it is not supposed to read the last column over and over again. no wonder its displaying the last column 3 times. it just needs to display each column once only. having identified my silly mistake, how to I rectify it? I am clueless. thanks again PsaltyDS! Your outer loop already iterates $i through the colums, just use $i there instead of $array[2]. Edited August 19, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
iceberg Posted August 20, 2008 Author Share Posted August 20, 2008 aaaah....oh my god! so near and yet so far... how stupid of me. thanks so much PsaltyDS....it works fine now. appreciate your kind help and patience. mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now