Jump to content
Sign in to follow this  
DanielTyrkiel

ActiveSheet.UsedRange.Value

Recommended Posts

DanielTyrkiel

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

Share this post


Link to post
Share on other sites
water

_ArrayDisplay has a transpose parameter.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
DanielTyrkiel

DUH! I'll try that

Thanks Water!

Share this post


Link to post
Share on other sites
water

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
DanielTyrkiel

I've added a few lines to the code in first post.

I think I have found a quick way to paste a largish table back into excel

What do you think?

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
DanielTyrkiel

wow, I must be NOOB LvL 002 if Water is asking me for suggestions :D

Share this post


Link to post
Share on other sites
water
:graduated:

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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  

×