water Posted July 13, 2016 Share Posted July 13, 2016 (edited) This script works just fine for me for entries with multiple, single or no Client Machines. Speed can be enhanced if needed What's missing in this example is some kind of error checking. But with the code I posted so get the message faster #include <Excel.au3> Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\test.xlsx") Global $aWorksheet = _Excel_RangeRead($oWorkbook) _ArrayDisplay($aWorksheet) For $i = 1 To UBound($aWorksheet, 1) - 1 $aMaschines = StringSplit($aWorksheet[$i][2], ",") If @error Then ; No separator found If $aMaschines[1] <> "" Then ; Client machine found _Excel_RangeWrite($oWorkbook, Default, $aMaschines[1], "D" & $i+1) EndIf Else _Excel_RangeWrite($oWorkbook, Default, $aMaschines[$aMaschines[0]], "D" & $i+1) EndIf Next Edited July 13, 2016 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
antmar904 Posted July 13, 2016 Author Share Posted July 13, 2016 @water The script runs then exit and does nothing. Here is a snippit of the excel file. LNTest.xlsx Link to comment Share on other sites More sharing options...
water Posted July 13, 2016 Share Posted July 13, 2016 (edited) I grabbed a screenshot of your workbook that consisted of 4 columns. This now works with your example file: #include <Excel.au3> Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\LNtest.xlsx") Global $aWorksheet = _Excel_RangeRead($oWorkbook) Global $hSplashtext = SplashTextOn("Progress", "Records processed ...", -1, 50) For $i = 1 To UBound($aWorksheet, 1) - 1 Sleep(50) If Mod($i, 10) = 0 Then ControlSetText($hSplashtext, "", "Static1", "Records processed ... " & $i) $aMaschines = StringSplit($aWorksheet[$i][1], ",") If @error Then ; No separator found If $aMaschines[1] <> "" Then ; Client machine found _Excel_RangeWrite($oWorkbook, Default, $aMaschines[1], "D" & $i + 1) EndIf Else _Excel_RangeWrite($oWorkbook, Default, $aMaschines[$aMaschines[0]], "C" & $i + 1) EndIf Next SplashOff() Edited July 13, 2016 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
antmar904 Posted July 13, 2016 Author Share Posted July 13, 2016 @water It worked your a genius. I took about 18 min to complete with 32176 rows. Link to comment Share on other sites More sharing options...
water Posted July 13, 2016 Share Posted July 13, 2016 This one is even faster: #include <Excel.au3> Global $iTimer = TimerInit() Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\LNtest.xlsx") Global $aWorksheet = _Excel_RangeRead($oWorkbook) Global $hSplashtext = SplashTextOn("Progress", "Records processed ...", -1, 50) Global $aTemp[UBound($aWorksheet, 1) - 1] For $i = 1 To UBound($aWorksheet, 1) - 1 If Mod($i, 10) = 0 Then ControlSetText($hSplashtext, "", "Static1", "Records processed ... " & $i) $aMaschines = StringSplit($aWorksheet[$i][1], ",") If @error Then ; No separator found If $aMaschines[1] <> "" Then ; Client machine found $aTemp[$i - 1] = $aMaschines[1] EndIf Else $aTemp[$i - 1] = $aMaschines[$aMaschines[0]] EndIf Next _Excel_RangeWrite($oWorkbook, Default, $aTemp, "C2") SplashOff() MsgBox(0, "Info", "Processing time: " & TimerDiff($iTimer)) Takes 4.3 seconds to process 32176 records compared to the previous version which took 460 seconds here My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
antmar904 Posted July 13, 2016 Author Share Posted July 13, 2016 Wow 5 sec now! Thank a million. Time to look over the script to understand it some more. Link to comment Share on other sites More sharing options...
water Posted July 13, 2016 Share Posted July 13, 2016 (edited) The slower script calls _Excel_RangeWrite for every cell, the faster stores all values in a temporary array and then writes all cells with a single call Edited July 13, 2016 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki 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