Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Data Access Efficiency: Arrays versus Worksheet Data

Hi All,
In my app I have a worksheet, DataStore, with "validating" tables
of character and numeric data. It's hidden and the
data changes rarely.

As I wrote the function below, I cloned it from the code
that loads two arrays from DataStore, at workbook
open.
1) reserved worksheet names
2) Those in 1) that each workbook must have.

(The arrays are global public declared variables)
The code works fine, and I have not done any timings
yet, but I began to wonder, Why have the arrays at all ?

What are the pro's and cons of having the function below
go directly after the cells in DataStore versus checking
the arrays as it does now? With a computer of decent size,
I would assume that just about all the Excel data is in
memory anyway.
Thanks, Neal

Function zWsNames_AllReqdF(IWrkBkName As String) As Boolean
' Check a workbook to see if all required worksheets are there.
Dim Qty As Integer
zWsNames_AllReqdF = True
For Qty = 1 To UBound(RmRsrvWsNamesAy) 'reserved w/s names
' Exist/NotExist homegrown worksheet function
If NotExist = zWs_ExistF(IWrkBkName, RmRsrvWsNamesAy(Qty)) Then
If RMbReqdWsNamesAy(Qty) = True Then 'required sheets
MsgBox RmRsrvWsNamesAy(Qty) & " worksheet is missing from
workbook." _
, vbCritical, "Workbook: " & IWrkBkName & " Error"
zWsNames_AllReqdF = False
End If
End If
Next Qty
End Function
--
Neal Z
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Data Access Efficiency: Arrays versus Worksheet Data

Neal,

You can read/write to an array about 100 times faster than reading or
writing to a worksheet cell. So if you are minipulating a lot of data,
always use arrays. Read the entire range you are working with into a
variant arrray, make the necessary changes then write the arrray back to the
range. Lightening fast.

My distributor sales forecast package uses ranges that have 50,000 elements.
I can change 5000 elements in less than 2 seconds using arrays. If I wrot
to cells with Application.ScreenUpdating = False, it would probably take 3
or 4 minutes. Of course using arrays can take a lot more memory so always
redimention the array when you are done with it!

APL

"Neal Zimm" wrote in message
...
Hi All,
In my app I have a worksheet, DataStore, with "validating" tables
of character and numeric data. It's hidden and the
data changes rarely.

As I wrote the function below, I cloned it from the code
that loads two arrays from DataStore, at workbook
open.
1) reserved worksheet names
2) Those in 1) that each workbook must have.

(The arrays are global public declared variables)
The code works fine, and I have not done any timings
yet, but I began to wonder, Why have the arrays at all ?

What are the pro's and cons of having the function below
go directly after the cells in DataStore versus checking
the arrays as it does now? With a computer of decent size,
I would assume that just about all the Excel data is in
memory anyway.
Thanks, Neal

Function zWsNames_AllReqdF(IWrkBkName As String) As Boolean
' Check a workbook to see if all required worksheets are there.
Dim Qty As Integer
zWsNames_AllReqdF = True
For Qty = 1 To UBound(RmRsrvWsNamesAy) 'reserved w/s names
' Exist/NotExist homegrown worksheet function
If NotExist = zWs_ExistF(IWrkBkName, RmRsrvWsNamesAy(Qty)) Then
If RMbReqdWsNamesAy(Qty) = True Then 'required sheets
MsgBox RmRsrvWsNamesAy(Qty) & " worksheet is missing from
workbook." _
, vbCritical, "Workbook: " & IWrkBkName & " Error"
zWsNames_AllReqdF = False
End If
End If
Next Qty
End Function
--
Neal Z



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Data Access Efficiency: Arrays versus Worksheet Data

My data's not nearly that big, but I'll take the tip.
thanks.
--
Neal Z


"alondon" wrote:

Neal,

You can read/write to an array about 100 times faster than reading or
writing to a worksheet cell. So if you are minipulating a lot of data,
always use arrays. Read the entire range you are working with into a
variant arrray, make the necessary changes then write the arrray back to the
range. Lightening fast.

My distributor sales forecast package uses ranges that have 50,000 elements.
I can change 5000 elements in less than 2 seconds using arrays. If I wrot
to cells with Application.ScreenUpdating = False, it would probably take 3
or 4 minutes. Of course using arrays can take a lot more memory so always
redimention the array when you are done with it!

APL

"Neal Zimm" wrote in message
...
Hi All,
In my app I have a worksheet, DataStore, with "validating" tables
of character and numeric data. It's hidden and the
data changes rarely.

As I wrote the function below, I cloned it from the code
that loads two arrays from DataStore, at workbook
open.
1) reserved worksheet names
2) Those in 1) that each workbook must have.

(The arrays are global public declared variables)
The code works fine, and I have not done any timings
yet, but I began to wonder, Why have the arrays at all ?

What are the pro's and cons of having the function below
go directly after the cells in DataStore versus checking
the arrays as it does now? With a computer of decent size,
I would assume that just about all the Excel data is in
memory anyway.
Thanks, Neal

Function zWsNames_AllReqdF(IWrkBkName As String) As Boolean
' Check a workbook to see if all required worksheets are there.
Dim Qty As Integer
zWsNames_AllReqdF = True
For Qty = 1 To UBound(RmRsrvWsNamesAy) 'reserved w/s names
' Exist/NotExist homegrown worksheet function
If NotExist = zWs_ExistF(IWrkBkName, RmRsrvWsNamesAy(Qty)) Then
If RMbReqdWsNamesAy(Qty) = True Then 'required sheets
MsgBox RmRsrvWsNamesAy(Qty) & " worksheet is missing from
workbook." _
, vbCritical, "Workbook: " & IWrkBkName & " Error"
zWsNames_AllReqdF = False
End If
End If
Next Qty
End Function
--
Neal Z




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading data arrays from multiple data files in excel Hankjam[_2_] Excel Discussion (Misc queries) 0 February 7th 08 08:29 PM
Excel worksheet retrieving data from Access [email protected] Links and Linking in Excel 1 May 8th 06 12:32 AM
Free Tool (Add-In) for Improving Your Data Processing Efficiency Danniel Chen Excel Programming 0 May 23rd 05 08:48 PM
access my data from my master worksheet while calculation is don. Kannan.Iyer Excel Worksheet Functions 1 April 6th 05 01:23 AM
Populating worksheet with data from Access EManning Excel Programming 0 August 3rd 04 09:33 PM


All times are GMT +1. The time now is 10:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"