Jump to content

Help: _ExcelReadSheetToArray with Time value


Recommended Posts

When I used the function, cell that has value as time (HH:mm, ex: 10:38:00 AM) showed in array as decimal (ex: 0.443055555555556.)

There's no parameter in the function to ask it to treat as text at least.

This line of code is to load the cell value into the returned array:

$avRET[$r][$c] = $oExcel.Activesheet.Cells($iStartRow + $r - 1, $iStartColumn + $c - 1).Value

So how can I change it so that it would return the value as Time which is what it was formatted on Excel sheet; or at least text?

I did change it to:

$avRET[$r][$c] = String($oExcel.Activesheet.Cells($iStartRow + $r - 1, $iStartColumn + $c - 1).Value)

But didn't work, I guess it was because of how Excel object deal with cell value.

Please help! Thanks.

Link to comment
Share on other sites

Thanks a lot! Never thought of that simple.

I modified the UDF on my PC to have another function to read all cells as text as you told, that way I can use the original one when I do need value.

I thought about modify the original function to have another parameter, but I think keep it as is is better way to do.

Link to comment
Share on other sites

Seems you are using a quite old version of the Excel UDF. The Excel UDF has been rewritten and is now faster and easier to use.

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

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