Jump to content

Need a help in Excel UDF (_Excel_RangeWrite)


Recommended Posts

Hi Everyone,

I am a beginner and I am currently learning and practicing what Autoit can do, so kindly pardon if it sound's silly.

What my program does ----> I had written a program where I have a FOR (i=0 to n) loop which is running for n times. Inside the FOR loop, contents of array is written into excel using _Excel_RangeWrite .

_Excel_RangeWrite($oExcelDoc, $oExcelDoc.Activesheet, $arrayname, "A1")

Problem ------> During every loop run the contents of column A is only altered

What i intend to do ------> For every loop run (i=0,1,2,3...) I want to write the array contents into respective next adjacent excel columns

i.e) For i=0 loop, every array content should be written in A Column of excel

For i = 1 loop, every array content should be written in B Column of excel.

 

Can anyone give me an idea of  how can i do this? Thanks 

Link to comment
Share on other sites

You can also transpose your array for example:

#include <Array.au3>
#include <Excel.au3>

Local $aArray[26] = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
$oExcel = _Excel_Open()
$oWorkbook = _Excel_BookNew($oExcel)
;~ Write Rows
_Excel_RangeWrite($oWorkbook, $oWorkbook.ActiveSheet, $aArray, 'A1')
_ArrayTranspose($aArray)
;~ Write Columns
_Excel_RangeWrite($oWorkbook, $oWorkbook.ActiveSheet, $aArray, 'A1')

 

Link to comment
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
 Share

×
×
  • Create New...