Jump to content

Array copy from active excel - (Moved)


VinMe
 Share

Recommended Posts

I am unable to execute the below script, my requirement is to copy the content from active excel sheet and to display the same.

Please let me know where i am missing!

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

Local $oExcel = _Excel_Open()
$LastRow2 = $oExcel.UsedRange.Rows.Count

$Tissue = _Excel_RangeRead($oExcel, Default, "E1:E" & $LastRow2)
$TshNr = _Excel_RangeRead($oExcel, Default, "F1:F" & $LastRow2)
_ArrayDisplay($Tissue)
_ArrayDisplay($TshNr)

Link to comment
Share on other sites

What do you mean by: " I am unable to execute the below script"? Do you get an error? Do youget wrong results?
What is the value of $LastRow2?
What is the value of @error and @extended after calling _Excel_RangeRead?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

@VinMe
Before saying that you don't receive any error, you should check for a returning error with an If condition.

If @error Then
    ConsoleWrite("Error: " & @error & @CRLF)
Else
    ; Continue with your script
EndIf

In this way, you know if there is an error, and which error you are facing.
Then, you should check if the array returned from _Excel_RangeRead() is effectively an array; you can do this with the function IsArray :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

How does the code posted work, you need to attach to a workbook first?

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

Local $oWorkbook = _Excel_BookAttach(@ScriptDir & "\Excelwb.xlsx")
Local $iLastRow = $oWorkbook.ActiveSheet.UsedRange.Rows.Count
Local $aTissue = _Excel_RangeRead($oWorkbook, Default, "E1:E" & $iLastRow)
Local $aTshNr = _Excel_RangeRead($oWorkbook, Default, "F1:F" & $iLastRow)
_ArrayDisplay($aTissue)
_ArrayDisplay($aTshNr)
;~ Or
Local $aArray = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("E:F"))
_ArrayDisplay($aArray)

 

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...