Jump to content

ActiveSheet.UsedRange.Value


Recommended Posts

Hi,

I have found that the above synthax returns an array of all cells used in the active sheet in excel. The benefit I'm trying to exploit is that the array is loaded in an instant!

My question is: Do you know if there is a parameter that transposes the array?

As it is, when checking with _ArrayDisplay(), the result is that columns from excel are as rows in the array.

It's not a big issue because I can code around it, but it would make it easier

here's my code:

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.8.1
Author: Daniel Tyrkiel

Script Function:
testing fast array loading

#ce ----------------------------------------------------------------------------

; Script Start

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

;setting hotkey to terminate the script in case it runs away in a loop
HotKeySet("{ESC}", "Terminate")

;navigate to the chase up log:
$sFilePath002 = FileOpenDialog("Choose a spreadsheet", @MyDocumentsDir, "All (*.*)")
If $sFilePath002 = "" Then Exit ;exit if "cancel" gets pressed
$oExcel = _ExcelBookOpen($sFilePath002)
If $oExcel = 0 Then
MsgBox(0, "", "failed to attach", 2) ;speak up if you can't attach
Exit
EndIf

;core of the test:
Local $aTest = $oExcel.ActiveSheet.UsedRange.Value
Local $fIsArray = IsArray($aTest)

If $fIsArray = 1 Then
_ArrayDisplay($aTest, "")
Else
MsgBox(0, "", "$aTest is not an array")
EndIf

Local $oExcelNew = _ExcelBookNew()
;_ExcelWriteSheetFromArray($oExcelNew, $aTest)
;ClipPut("")
;_ArrayToClip($aTest)
$oExcelNew.ActiveSheet.Range("A1:I100").Value = $aTest

;Functions_______________________________________________________________________________________________________________________________________

Func Terminate()
Exit 0
EndFunc ;==>Terminate
Edited by DanielTyrkiel
Link to comment
Share on other sites

_ArrayDisplay has a transpose parameter.

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

If this is too slow you could try the Excel transpose method.

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

I have already started to the Excel UDF (will later become part of AutoIt).

The functions _Excel_RangeRead and _Excel_RangeWrite allow to process a string (single cell), 1D array (column), 2D array (range of rows/columns). They use the methods you describe.

Suggestions for the UDF are always welcome!

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

:graduated:

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...