Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 905
Default CurrentArray broken in xl2003? xl2007?

According to VBA Help, the CurrentArray property should behave as follows:
"If the specified cell is part of an array, returns a Range object that
represents the entire array".

And it does exactly that when it is used in the testit macro below.

But it does not seem to behave that way when it is used in the same way in
the funcit function below.

Is CurrentArray broken in my revision of Excel, namely Excel 2003
(11.5612.5606) and VBA 6.3 (9969, 6.4.8869), part of MS Office 2003 Sm Busn
Ed?

Does funcit() behave like testit() in some earlier or later revisions of
Excel/VBA, e.g. Excel 2007?

Is there some reasonable way to make CurrentArray work in funcit() in my
revision of Excel? Or is there an alternative to CurrentArray that I could
use for the same purpose?


Details....

Suppose A1:B2 contains some array formula. Suppose C1 contains the formula
=funcit().

Be sure that C1 (or any cell other than one of A1:B2) is selected in Excel.
This is to demonstrate that CurrentArray is not limited to ActiveCell, which
is used in the Help page.

Execute the testit macro. The output, copy-and-pasted from the Immediate
Window, is:

testit: addr $A$1:$B$2, hasArray True, currArray $A$1:$B$2
addr $A$1, hasArray True, currArray $A$1:$B$2
addr $B$1, hasArray True, currArray $A$1:$B$2
addr $A$2, hasArray True, currArray $A$1:$B$2
addr $B$2, hasArray True, currArray $A$1:$B$2

Note that CurrentArray for each cell is indeed the entire array range.

Now, with C1 selected, press F2 and Enter to execute the funcit function.
My output is:

funcit: callcnt 1, addr $A$1:$B$2, hasArray True, currArray $A$1:$B$2
addr $A$1, hasArray True, currArray $A$1
addr $B$1, hasArray True, currArray $B$1
addr $A$2, hasArray True, currArray $A$2
addr $B$2, hasArray True, currArray $B$2

Note that CurrentArray for each cell is __not__ the entire array range.


Option Explicit
Private callcnt As Long


Sub testit()
Dim cell As Range, myStr As String, myrng As Range
Set myrng = Range("a1:b2")
With myrng
myStr = "testit: addr " & .Address & _
", hasArray " & .HasArray & _
", currArray " & .CurrentArray.Address
End With
For Each cell In myrng
With cell
myStr = myStr & Chr(10) & "addr " & .Address & _
", hasArray " & .HasArray & _
", currArray " & .CurrentArray.Address
End With
Next cell
Debug.Print myStr
MsgBox myStr
End Sub


Function funcit()
Dim cell As Range, myStr As String, myrng As Range
callcnt = callcnt + 1
Set myrng = Range("a1:b2")
With myrng
myStr = "funcit: callcnt " & callcnt & _
", addr " & .Address & _
", hasArray " & .HasArray & _
", currArray " & .CurrentArray.Address
End With
For Each cell In myrng
With cell
myStr = myStr & Chr(10) & "addr " & .Address & _
", hasArray " & .HasArray & _
", currArray " & .CurrentArray.Address
End With
Next cell
Debug.Print myStr
MsgBox myStr
End Function

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
XL2003 toolbar macros in XL2007 Paul Martin[_2_] Excel Programming 1 September 23rd 09 02:20 PM
XL2007 and XL2003 LeeCC Excel Discussion (Misc queries) 2 December 18th 08 04:44 PM
Conditional formatting different on XL2007 than XL2003 Stan Excel Discussion (Misc queries) 0 July 16th 08 06:24 PM
Upgrade options from XL2003/VBA/VB6 to XL2007/VB.NET ... Boesman Excel Programming 0 August 20th 07 04:57 PM
XL2007 vs XL2003 Art Excel Programming 10 April 21st 07 04:32 PM


All times are GMT +1. The time now is 04:16 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"