This is the version I am using

        tmprange.Value2 = .Evaluate("IF(ROW(),round(" &
tmprange.Address & ",2))")

On Fri, Apr 13, 2012 at 12:42 AM, Asa Rossoff <a...@lovetour.info> wrote:
> Hi Rajan,
> I think it's been a series of topics.  I don't think I could summarize them.
> Maybe Domain has a thought on what was most valuable.
>
> Asa
>
> -----Original Message-----
> From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
> On Behalf Of Rajan_Verma
> Sent: Thursday, April 12, 2012 12:32 AM
> To: excel-macros@googlegroups.com
> Subject: RE: $$Excel-Macros$$ Argh. Previously posted evaluate function
> replacing loop has unnoticed major error
>
> Hi Asa/Domain,
> So what is conclusion of this long discussion.
>
> Rajan.
>
> -----Original Message-----
> From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
> On Behalf Of Asa Rossoff
> Sent: Apr/Thu/2012 12:33
> To: excel-macros@googlegroups.com
> Subject: RE: $$Excel-Macros$$ Argh. Previously posted evaluate function
> replacing loop has unnoticed major error
>
>> Agree row and column is not a worksheet concept.
> Not sure if this is a typo or miscommunication - I said row/column is a
> worksheet concept (whatever the wisdom of my statement might be).
>
>> But it is as you say a function of the way arrays are stored in memory.
> Not row and column - but I believe the redim preserve limitation is.
> On second thought, see
> http://msdn.microsoft.com/en-us/library/w8k3cys2%28v=vs.71%29.aspx .
> If VBA/VB6 is like VB.Net, REDIM PRESERVE copies the array anyway.  Not sure
> exactly what the reasoning for the limitation is, although I have to think
> it has something to do with the efficiency of the operation.  But even a
> slightly less efficient operation would be better than a much less efficient
> operation of writing ones own routine to copy the array out, destructively
> redim the array, and copy the desired element back which might be what you'd
> have to do without TRANSPOSE or if you have more than two dimensions.  It
> might be OK in a compiled language (such as any other VB variant), but still
> a pain.  In VBA it adds a significant inefficiency for a large array.
>
>> And they might as well make it match the way excel is used.
> VBA isn't Excel-specific.  It is the language of all Office applications
> (and some third-party software I think).  It is also a variant of Visual
> Basic which predates VBA.  We basically get Visual Basic which wasn't
> designed particularly for Excel or even use as a macro language, and an API
> added by Excel with additional Excel-specific objects.  We're lucky to have
> TRANSPOSE, as it is not available from even VBA running in Access, Word, or
> Powerpoint (without using COM automation to an instance of Excel).
>
>> It also defines the most efficient way to nest loops in multidimension
> arrays.
> Perhaps.  I wouldn't expect looping through elements of an array to go
> faster or slower in any particular order.  Since you're only retrieving one
> value at a time, I would think the way the values are arranged in memory
> would be irrelevant.
>
>> It really makes no sense to say you can increase all dimension if
>> tossing
> the
>> contents but not if keeping them.  Somebody took an implementation
> shortcut.
> If so it was a long time ago in a predecessor language.  As to the reason
> Excel provides ranges as an array(row, column) is probably to make it
> intuitive, at the cost of REDIM Preserve usefullness when working with this
> arrays.
>
> worksheets are arranged row, column
> assigning it to an array variable and getting (column, row) would be very
> confusing.
>
> And then, any array you assigned to a range would essentially be transposed
> automatically, too, if you could reassign the array you retrieved from a
> range.
>
> Anyway, sorry!
> Asa
>
> -----Original Message-----
> From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
> On Behalf Of Domain Admin
> Sent: Wednesday, April 11, 2012 10:22 PM
> To: excel-macros@googlegroups.com
> Subject: Re: $$Excel-Macros$$ Argh. Previously posted evaluate function
> replacing loop has unnoticed major error
>
> Agree row and column is not a worksheet concept.
> But it is as you say a function of the way arrays are stored in memory.
> And they might as well make it match the way excel is used.
> It also defines the most efficient way to nest loops in multidimension
> arrays.
> Redim preserve does not say you can only expand columns, it says you can
> only expand the last dimension so if you have a 5 dimension array you can
> only expand dimension 5.  The rightmost dimension changes fastest so in
> memory for a 2 dimension array you have all of row 1's columns then all of
> row 2's columns etc which means in a loop you want the column loop to be the
> inner loop.  True of every language though some reverse the precedence
> order.  I think they should have made redim preserve have the first
> dimension be the one that can change.  But then since they create a new copy
> anyway I see no reason all dimensions can not change.
> It really makes no sense to say you can increase all dimension if tossing
> the contents but not if keeping them.  Somebody took an implementation
> shortcut.
>
> On Wed, Apr 11, 2012 at 8:32 PM, Asa Rossoff <a...@lovetour.info> wrote:
>>> So if redim preserve will only let you extend the column value which
>>> I do not get as that is almost never what anyone would want, can you
>>> transpose the array, do the redim, then transpose back?
>>
>> The concept of row and column is a worksheet concept. In VBA an array
>> doesn't have a "physical orientation" like that.  In fact, an array
>> can
> have
>> a dozen dimension if needed or wanted.  It's more of a tree (branching
>> / parent-child, etc.) concept than row and column in VBA
>>
>> The reason for the REDIM PRESERVE restriction is most likely related
>> to
> the
>> way the array is arranged in memory.  VBA can change the final
>> dimension "in-place" in memory without copying the whole array to a
>> new memory location.  TRANSPOSE will create a new copy of the array
>> (at least in vba
> --
>> not necessarily with each use in a worksheet formula -- there I just
>> don't know).
>>
>> Yes, for a two dimensional array, transposing should let you redim the
> other
>> dimension, and transposing again will get you your originial array
>> arrangement with the preserved data.  At the cost of copying the array
>> in memory twice.
>>
>> Asa
>>
>> -----Original Message-----
>> From: Asa Rossoff [mailto:a...@lovetour.info]
>> Sent: Wednesday, April 11, 2012 6:51 PM
>> To: 'excel-macros@googlegroups.com'
>> Subject: RE: $$Excel-Macros$$ Argh. Previously posted evaluate
>> function replacing loop has unnoticed major error
>>
>>> Whatever would make you think of it that being the case?
>> Sorry, makes me think of what being the case?
>>
>> -----Original Message-----
>> From: excel-macros@googlegroups.com
>> [mailto:excel-macros@googlegroups.com]
>> On Behalf Of Domain Admin
>> Sent: Wednesday, April 11, 2012 6:18 PM
>> To: excel-macros@googlegroups.com
>> Subject: Re: $$Excel-Macros$$ Argh. Previously posted evaluate
>> function replacing loop has unnoticed major error
>>
>> Whatever would make you think of it that being the case?
>>
>> So if redim preserve will only let you extend the column value which I
>> do not get as that is almost never what anyone would want, can you
>> transpose the array, do the redim, then transpose back?
>>
>> On Wed, Apr 11, 2012 at 6:10 PM, Asa Rossoff <a...@lovetour.info> wrote:
>>> rounding a range results in an array.  Evaluate evaluates array
>>> formulas
>> and
>>> returns array results.  So, the fact that it didn't with the simple
>>> ROUND formula is strange.  transpose switches rows for columns, and a
>>> second transpose switches them back.  So you get the original array.
>>> No idea
> why
>>> this was needed..
>>>
>>> -----Original Message-----
>>> From: excel-macros@googlegroups.com
> [mailto:excel-macros@googlegroups.com]
>>> On Behalf Of Domain Admin
>>> Sent: Wednesday, April 11, 2012 6:02 PM
>>> To: excel-macros@googlegroups.com
>>> Subject: Re: $$Excel-Macros$$ Argh. Previously posted evaluate
>>> function replacing loop has unnoticed major error
>>>
>>> Ok that does appear to work, but I don't get it.  How does nested
>>> transposes function to make this work correctly?  It would appear to
>>> the novice that all you did was transpose it then transpose it back
>>> then whatever...
>>>
>>> Is transposing an array the answer to my other new post about redim
>>> preserve?
>>>
>>> On Wed, Apr 11, 2012 at 5:53 PM, Asa Rossoff <a...@lovetour.info> wrote:
>>>> To retrieve a multi-column array I resorted to
>>>> "transpose(transpose(round(a1:b10,2)))" form.
>>>>
>>>>
>>>>
>>>> From: Asa Rossoff [mailto:a...@lovetour.info]
>>>> Sent: Wednesday, April 11, 2012 5:18 PM
>>>> To: 'excel-macros@googlegroups.com'
>>>> Subject: RE: $$Excel-Macros$$ Argh. Previously posted evaluate
>>>> function replacing loop has unnoticed major error
>>>>
>>>>
>>>>
>>>> Hi Howard,
>>>>
>>>> Seems like an Excel bug.. Sorry for not testing the suggestion.
> Evaluate
>>>> may not be fully documented for a reason.  However, it is a great
>>>> useful function, just if you aren't getting the result you expect,
>>>> you may have
>>> to
>>>> look for a workaround.  I just posted a query in a developers forum
>>>> with aomse big hitters to see if I can get an explanation for what
>>>> you're
>>> seeing,
>>>> but in the meantime, here is a workaround.
>>>>
>>>>
>>>>
>>>> 1.       What you've seen with your use of Evaluate is evaluate
> returning
>>>> only a single value -- the first value in the array, rather than the
>> whole
>>>> array as Evaluate usually does.
>>>>
>>>> 2.       The INDEX function can be use to extract a reference to any
>>>> position in an array, or a whole row or column from an array.
>>>>
>>>> 3.       Here is a modification of your statement that works in my
>>>> test
>> by
>>>> using index to specify to return the first column from the array
>>>> (which
>> of
>>>> course is the whole array in this case):
>>>>
>>>> tmprange.Value2 = .Evaluate("index(round(" & tmprange.Address &
>> ",2),,1)")
>>>>
>>>>
>>>>
>>>> I used Value2 since it's usually faster, but you can use Value if
>>>> you prefer.  INDEX is the relevant change.
>>>>
>>>>
>>>>
>>>> Asa
>>>>
>>>>
>>>>
>>>> From: excel-macros@googlegroups.com
>> [mailto:excel-macros@googlegroups.com]
>>>> On Behalf Of tangledweb
>>>> Sent: Wednesday, April 11, 2012 2:28 PM
>>>> To: excel-macros@googlegroups.com
>>>> Subject: $$Excel-Macros$$ Argh. Previously posted evaluate function
>>>> replacing loop has unnoticed major error
>>>>
>>>>
>>>>
>>>> I used the evaluate function below to replace the commented out loop
>>> portion
>>>> for better performance in rounding off all the cells in a range.
>>>>
>>>> It was certainly fast and it performed the round function correctly
>>>> but
>> it
>>>> also replaced every single cell in the range with the value of the
>>>> first
>>>>
>>>> cell (ok you can laugh now).  Any idea what is wrong with it?  Kind
>>>> of
>>> hard
>>>> to debug a single line of code.
>>>>
>>>>
>>>>
>>>>     With Sheets(RawData)
>>>>         Set tmprange = .Range(.Cells(2, 3), .Cells(stoprawdata, 7))
>>>>         tmprange.Value = .Evaluate("round(" & tmprange.Address &
>>>> ",2)")
>>> 'use
>>>> evaluate instead of code below
>>>> '        For Each onecell In tmprange '            onecell.Value =
>>>> WorksheetFunction.Round(onecell, 2) '        Next onecell
>>>>     End With
>>>>
>>>> --
>>>> FORUM RULES (986+ members already BANNED for violation)
>>>>
>>>> 1) Use concise, accurate thread titles. Poor thread titles, like
>>>> Please Help, Urgent, Need Help, Formula Problem, Code Problem, and
>>>> Need Advice
>>> will
>>>> not get quick attention or may not be answered.
>>>>
>>>> 2) Don't post a question in the thread of another member.
>>>>
>>>> 3) Don't post questions regarding breaking or bypassing any security
>>>> measure.
>>>>
>>>> 4) Acknowledge the responses you receive, good or bad.
>>>>
>>>> 5) Cross-promotion of, or links to, forums competitive to this forum
>>>> in signatures are prohibited.
>>>>
>>>> NOTE : Don't ever post personal or confidential data in a workbook.
> Forum
>>>> owners and members are not responsible for any loss.
>>>>
>>>>
>>>
>>
> ----------------------------------------------------------------------------
>>> --------------------------
>>>> To post to this group, send email to excel-macros@googlegroups.com
>>>>
>>>> --
>>>> FORUM RULES (986+ members already BANNED for violation)
>>>>
>>>> 1) Use concise, accurate thread titles. Poor thread titles, like
>>>> Please Help, Urgent, Need Help, Formula Problem, Code Problem, and
>>>> Need Advice
>>> will
>>>> not get quick attention or may not be answered.
>>>>
>>>> 2) Don't post a question in the thread of another member.
>>>>
>>>> 3) Don't post questions regarding breaking or bypassing any security
>>>> measure.
>>>>
>>>> 4) Acknowledge the responses you receive, good or bad.
>>>>
>>>> 5) Cross-promotion of, or links to, forums competitive to this forum
>>>> in signatures are prohibited.
>>>>
>>>> NOTE : Don't ever post personal or confidential data in a workbook.
> Forum
>>>> owners and members are not responsible for any loss.
>>>>
>>>>
>>>
>>
> ----------------------------------------------------------------------------
>>> --------------------------
>>>> To post to this group, send email to excel-macros@googlegroups.com
>>>
>>> --
>>> FORUM RULES (986+ members already BANNED for violation)
>>>
>>> 1) Use concise, accurate thread titles. Poor thread titles, like
>>> Please Help, Urgent, Need Help, Formula Problem, Code Problem, and
>>> Need Advice
>> will
>>> not get quick attention or may not be answered.
>>>
>>> 2) Don't post a question in the thread of another member.
>>>
>>> 3) Don't post questions regarding breaking or bypassing any security
>>> measure.
>>>
>>> 4) Acknowledge the responses you receive, good or bad.
>>>
>>> 5)  Cross-promotion of, or links to, forums competitive to this forum
>>> in signatures are prohibited.
>>>
>>> NOTE  : Don't ever post personal or confidential data in a workbook.
> Forum
>>> owners and members are not responsible for any loss.
>>>
>>>
>>
> ----------------------------------------------------------------------------
>>> --------------------------
>>> To post to this group, send email to excel-macros@googlegroups.com
>>>
>>> --
>>> FORUM RULES (986+ members already BANNED for violation)
>>>
>>> 1) Use concise, accurate thread titles. Poor thread titles, like
>>> Please
>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need
>> Advice
> will
>> not get quick attention or may not be answered.
>>>
>>> 2) Don't post a question in the thread of another member.
>>>
>>> 3) Don't post questions regarding breaking or bypassing any security
>> measure.
>>>
>>> 4) Acknowledge the responses you receive, good or bad.
>>>
>>> 5)  Cross-promotion of, or links to, forums competitive to this forum
>>> in
>> signatures are prohibited.
>>>
>>> NOTE  : Don't ever post personal or confidential data in a workbook.
> Forum
>> owners and members are not responsible for any loss.
>>>
>>>
>>
> ----------------------------------------------------------------------------
>> --------------------------
>>> To post to this group, send email to excel-macros@googlegroups.com
>>
>> --
>> FORUM RULES (986+ members already BANNED for violation)
>>
>> 1) Use concise, accurate thread titles. Poor thread titles, like
>> Please Help, Urgent, Need Help, Formula Problem, Code Problem, and
>> Need Advice
> will
>> not get quick attention or may not be answered.
>>
>> 2) Don't post a question in the thread of another member.
>>
>> 3) Don't post questions regarding breaking or bypassing any security
>> measure.
>>
>> 4) Acknowledge the responses you receive, good or bad.
>>
>> 5)  Cross-promotion of, or links to, forums competitive to this forum
>> in signatures are prohibited.
>>
>> NOTE  : Don't ever post personal or confidential data in a workbook.
>> Forum owners and members are not responsible for any loss.
>>
>>
> ----------------------------------------------------------------------------
>> --------------------------
>> To post to this group, send email to excel-macros@googlegroups.com
>>
>> --
>> FORUM RULES (986+ members already BANNED for violation)
>>
>> 1) Use concise, accurate thread titles. Poor thread titles, like
>> Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
> not get quick attention or may not be answered.
>>
>> 2) Don't post a question in the thread of another member.
>>
>> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>>
>> 4) Acknowledge the responses you receive, good or bad.
>>
>> 5)  Cross-promotion of, or links to, forums competitive to this forum
>> in
> signatures are prohibited.
>>
>> NOTE  : Don't ever post personal or confidential data in a workbook.
>> Forum
> owners and members are not responsible for any loss.
>>
>>
> ----------------------------------------------------------------------------
> --------------------------
>> To post to this group, send email to excel-macros@googlegroups.com
>
> --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
> not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5)  Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE  : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
> ----------------------------------------------------------------------------
> --------------------------
> To post to this group, send email to excel-macros@googlegroups.com
>
> --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
> not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5)  Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE  : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
> ----------------------------------------------------------------------------
> --------------------------
> To post to this group, send email to excel-macros@googlegroups.com
>
> --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
> not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5)  Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE  : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
> ----------------------------------------------------------------------------
> --------------------------
> To post to this group, send email to excel-macros@googlegroups.com
>
> --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
> Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not 
> get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5)  Cross-promotion of, or links to, forums competitive to this forum in 
> signatures are prohibited.
>
> NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
> owners and members are not responsible for any loss.
>
> ------------------------------------------------------------------------------------------------------
> To post to this group, send email to excel-macros@googlegroups.com

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to