Jump to content

Recommended Posts

Firs of all, i'm sorry for my bad english, but i'm brazilian!

I've modified many functions of Excel.au3 to make it much more fast and created anothers functions

the function list is above:

Functions inside UDF:



_ExcelFormatR1C1ToA1($iRowFrom, $iColFrom, $iRowTo = "", $iColTo = "")


_ExcelReadSheetToArrayEX($oExcel, $iStartRow = 1, $iStartColumn = 1, $iRowCnt = 0, $iColCnt = 0, $iColShift = 0)

_ExcelPasteSpecial($oExcel, $sRange, $xPasteType = -4104, $xPasteSpecialOp = -4142)

_ExcelFormatPainter($oExcel, $sRangeFrom, $sRangeTo = 0, $xPasteType = -4104, $xPasteSpecialOp = -4142)

_ExcelWriteSheetFromArrayEx($oExcel, $aArray, $iStartRow = 1, $iStartColumn = 1, $iArrayRowStart = 0, $iArrayColStart = 0)

_ExcelWriteArrayEX($oExcel, $aArray, $iStartRow = 1, $iStartColumn = 1, $iArrayRowStart = 0, $iDirection = 0)

if someone wants to fix my specifications can be at ease!

in the attached file have a examples of functions!


functions that are written by other people and i just modified, i left specified within the UDF

I hope it is useful to you, it's much more fast than original functions!

Thanks a lot!



;Generate an Array
Local $aArray[100][15]

For $i = 0 To 99
For $j = 0 To 14
$aArray[$i][$j] = "Line: " & $i + 1 & " - Col: " & $j + 1

;Create Excel Object
Local $oExcel = _ExcelBookNew()

;Write a 2d Array to Excel with default values (start in R1C1 cell and write all itens in array).
MsgBox(0,'',"Press OK to write an Array to Excel.")
_ExcelWriteSheetFromArrayEx($oExcel, $aArray)

;Format 2 First's lines.
MsgBox(0,'',"Press OK to format the 2 first Excel cells.")
With $oExcel.ActiveSheet.Range("A1:O100")
.HorizontalAlignment = 3
.Borders.LineStyle = 1
$oExcel.ActiveSheet.Range("A1:O1").Interior.Color = 0xDAC0CC
$oExcel.ActiveSheet.Range("A2:O2").Interior.Color = 0xF0B00A
$oExcel.ActiveSheet.Range("A2:O2").Font.Bold = True

;Copy this style to all anothers Cells with _ExcelFormatPainter
MsgBox(0,'',"Press OK to copy the style of the 2 first's cells to to all anothers cells.")
_ExcelFormatPainter($oExcel, "A1:O2", 0, $xlPasteFormats, $xlPasteSpecialOperationNone)

;Read all data to array
MsgBox(0,'',"Press OK to read all cells to and array.")
Local $aCells = _ExcelReadSheetToArrayEX($oExcel)

;read 3 columns from Excel starting from 5nd and 50 rows starting from 1st row
MsgBox(0,'',"Press OK to read 50 rows and 3 cols and to and array.")
Local $aCells = _ExcelReadSheetToArrayEX($oExcel, 1, 5, 50, 3)


;Create another Excel Object
Local $oExcel = _ExcelBookNew()

;Write an Array to Excel Starting from 50 row and 12 col of array and write it starting from 2nd row and 3rd col of excel
MsgBox(0,'',"Press OK to write an Array to Excel.")
_ExcelWriteSheetFromArrayEx($oExcel, $aArray, 2, 3, 50, 12)
MsgBox(0,'',"Press OK to Close.")

;Write an 1D Array
Local $oExcel = _ExcelBookNew()
Local $aArray[5] = ["LocoDarwin", "Jon", "big_daddy", "DaleHolm", "GaryFrost"]
MsgBox(0,'',"Press OK to write an Array to Excel.")
_ExcelWriteArrayEX($oExcel, $aArray) ; Write the Array Horizontally
_ExcelWriteArrayEX($oExcel,$aArray, 5, 1, 0, 1) ; Write the Array Vertically, starting on the 5th Row

MsgBox(0,'',"Press OK to Exit.")


Edited by golfinhu

Share this post

Link to post
Share on other sites


I've already tried and tested, as you know golfinhu, this one: _ExcelReadSheetToArrayEX($oExcel, $iStartRow = 1, $iStartColumn = 1, $iRowCnt = 0, $iColCnt = 0, $iColShift = 0)

Its extremely fast, 10 x 's as fast actually, if not faster, and works GREAT! I'm not sure what corners you cut to increase the time, but man, it produces the same results, and 1000x faster!

I use it most every one of my apps I build for work. I can't think you enough. As you know, I requested you to do the same with the_ExcelWriteSheetFromArrayEx

But this is even better. So many newer faster functions to play with. I can't wait to get my hands on them! Its like its my birthday!

As soon as I get a chance to test the new ones above, I'll post back here and let you know. Thanks again!

Share this post

Link to post
Share on other sites

Hi golfinhu,

perfect !!!! :ILA2:

I can't belive the speed.

Please keep on working at the other functions.

Thanks for sharing!



Share this post

Link to post
Share on other sites

Rename the downloa


The ExcelEx in the Zip file seems broken and can't be extracted ?



Rename the downloaded file to ExcelEx.rar.gz. Extracting that will result in a ExcelEX.rar file that will then extract correctly.

Share this post

Link to post
Share on other sites

I downloaded the ExcelEX.rar file to Windows 7 today and was able to unrar/unzip it using 7Zip without problems.

My UDFs and Tutorials:


Active Directory (NEW 2020-03-26 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-03-21 - Version - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version - Download - General Help & Support - Wiki

ADO - Wiki, WebDriver - Wiki


Share this post

Link to post
Share on other sites

I downloaded the ExcelEX.rar file to Windows 7 today and was able to unrar/unzip it using 7Zip without problems.

I know, downloading compressed files off the forum still works for many of us, but as of a few months ago, not for some of us. Both my work and home machines have the problem, BrewManNH has a machine with the problem, and apparently ptrex too. if I searched around the forums I could probably find a dozen "Your zip file is bad!" comments related to the issue. Compressed files downloaded from the forum are coming down compressed a second time in the GZip format. I started a thread in the "chat" forum about it.

Edit: Using 7Zip may also be a work-around for the issue, as I only have WinZip and WinRar installed.

Edited by Spiff59

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • By Zaoka
      Hi guys,
      i have simple report in PowerPivot that shows Orders (Values) by Regions (Row) and Weeks (Columns). In Filter field is WeekDAYS (Monday,Tuesday,Wednesday,Thursday etc )
      how to filter WeekDAYS Filed on WEEKDAYYesterday with autoit ?
      my junky try
      #include <Date.au3> #include <Excel.au3> Local $sWEEKDAYYesterday = _DateDayOfWeek(@WDAY-1) Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookOpen($oExcel, "C:\Users\.......\Orders.xlsb") Sleep (5000) $oExcel.ActiveWorkbook.RefreshAll Sleep (5000) $oExcel.Application.Sheets("Sheet1").PivotTables("PivotTable1").PivotFields("WeekDAYS").PivotFilters($sWEEKDAYYesterday)  
      Error result
      $oExcel.Application.Sheets("PivotTable1").PivotTables("PivotTable1").PivotFields("WeekDAYS").PivotFilters($sWEEKDAYYesterday) $oExcel.Application^ ERROR  
    • By rdaneelol
      I have a strange behavior in an Autoit program.  
      The program works perfectly in the original environment I created the program for - for Windows 7 and Office  2010.
      My workplace is migrating to Windows 10 with Office 2016.  When I run this program in that new environment,  the code actually executes without any errors, however, the excel process which was opened to read a spreadsheet/workbook does not close while the program is running.  If you exit the program, the excel process ends at that point...
      I could ignore this behavior - one little excel process hanging out there is not going to kill anything, however - it just bugs me !
      While troubleshooting the issue, I placed a number of error checks after the excel close - and the close actually reports that it is successful. 
      I tried a few varieties of closing the excel process, and none of the methods tried seemed to actually work as well at the one in my code - the only downside being that it has to wait until the program finishes to actually close.
      Any ideas on why an excel close would hang until program exit ?
      Local $oExcel = _Excel_Open(False, False, False, False, True) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $oWorkbook = _Excel_BookOpen($oExcel, $sUserRoleMenuXLS, False, true ) If @error Then     MsgBox($MB_SYSTEMMODAL, "Excel UDF", "Error opening workbook '" & $sUserRoleMenuXLS & @CRLF & "@error = " & @error & ", @extended = " & @extended)     _Excel_Close($oExcel, False, False)  Exit EndIf ;  this section will find the user id in the first 3 columns of the user/menu spreadsheet, and if it finds it - returns the value stored in the cell 2 locations to the right... With $oExcel.ActiveSheet.Range("A:C").Find (@UserName)     $Match = .Find (@UserName)     If (Not IsObj($Match)) or (stringlen($Match.Offset(0, 2).value) = 0)    Then         MsgBox($MB_SYSTEMMODAL, 'UIPLauncher Error', 'No Menu assigned for user - Contact Support.') ; Display a warning if the script isn't compiled or the file doesn't exist.         ;_Excel_BookClose($oWorkbook, False)         _Excel_Close($oExcel, false, false)         Exit     Else         Local  $cResult = $Match.Offset(0, 2).value     EndIf EndWith $oWorkbook.Saved = True _Excel_BookClose($oWorkbook, False) _Excel_Close($oExcel, false, false) ;close does not seem to work on windows 10 and office 2016  
    • By VinMe
      $aTdslist = _Excel_RangeRead($oWorkbook1, Default, "B1:B" & $LastRow) $aTDSLOC = _Excel_RangeRead($oWorkbook1, Default, "H1:H" & $LastRow) MsgBox(0, "TAKSY OUTPUT LAST ROW", $LastRow) _ArrayTrim($aTDSLOC, 1, 1) _Excel_RangeWrite($oWorkbook1, $oWorkbook1.ActiveSheet, $aTDSLOC, "H2") $oWorkbook1.Sheets("DS_List").Activate $mLastRow = $oWorkbook1.ActiveSheet.UsedRange.Rows.Count $aMdslist = _Excel_RangeRead($oWorkbook1, Default, "B1:B" & $mLastRow) MsgBox(0, "MASTER OUTPUT LAST ROW", $mLastRow) _Excel_RangeReplace($oWorkbook1, Default, "F2:F" & $mLastRow, "N/A", "n/a") ;check the requiremetn $aMLOC = _Excel_RangeRead($oWorkbook1, Default, "F1:F" & $mLastRow) ;LOC NUMBER NEEDS TO BE REPLACED WITH.. _ArrayDisplay($aTDSLOC) _ArrayDisplay($aMLOC) _ArrayDisplay($aMdslist) ;DATA COMPARISION BETWEEN TAKSY LIST WITH LOC FROM SAP TO MASTER LIST WITH LOC. $oWorkbook1.Sheets("OUTPUT").Activate For $i = 1 To $LastRow - 1 For $j = 1 To $mLastRow - 1 If $aTdslist[$i] == $aMdslist[$j] And $aTDSLOC[$i] <> $aMLOC[$j] Then $oExcel.ActiveSheet.Range("H" & $i + 2).Interior.ColorIndex = 3 EndIf If $aTdslist[$i] == $aMdslist[$j] And $aMLOC[$j] == "n/a" And _Excel_RangeRead($oWorkbook1, Default, "I" & ($i + 2)) == "NO KIT" Then $oExcel.ActiveSheet.Range("H" & $i + 2).Interior.ColorIndex = 2 _Excel_RangeWrite($oWorkbook1, $oWorkbook1.ActiveSheet, "*", "H" & ($i + 2)) EndIf Next Next MsgBox($MB_SYSTEMMODAL, "Status", "Loc extraction, comparision and consolidation is Done", 2) DEAR TEAM, I am facing issue w.r.t subscript errors kindly help me in solving...
    • By VinMe
      $oWorkbook = _Excel_BookAttach($sWorkbook) $oWorkbook.sheets("Sheet1").activate Local $sMSN = InputBox("MSN NO", "Enter MSN in XX FORMAT", "") _Excel_FilterSet($oWorkbook, $oWorkbook.activesheet, "AF1", 32, $sMSN) can anyone help me here, excel filer is not working with the above code.. attached excel
      input: 12
      Thank you in advance!!
      to check.xlsx
    • By Rskm
      Hi, I am using excel as input media for my program. The excel file (i tried with .xls, .xlsx and .xlsm format) has inputs which the autoit script reads during the run and performs few calculations. Some times (not always), after the run, when i try to open the excel file manually, the file doesnt open at all in excel. see the screenshot attached. However, if the execute the autoit script, the scripts still reads the existing data from that excel and performs the calcs. I copied the excel file to another computer and there too, it doesnt open.  So, after this, i cannot edit the excel forever (if i need to change any inputs). It is only this particular file that got affected. other excel files works normal.  What could be the problem here.  please help as this is a new challenge for me during my program development. 

  • Create New...