It was made to work with this change. Speculation is there is a VBA bug. There is no reason for the Len except maybe to accomplish what this does which is to change the code enough so that it compiles/interprets correctly
tmprange.Value2 = .Evaluate("transpose(transpose(round(" & tmprange.Address & ",2)))") On Wed, Apr 11, 2012 at 11:56 PM, Rajan_Verma <rajanverma1...@gmail.com> wrote: > Use it with IF and Len() > > Rajan, > > -----Original Message----- > From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com] > On Behalf Of Domain Admin > Sent: Apr/Thu/2012 02:51 > To: excel-macros@googlegroups.com > Subject: Re: $$Excel-Macros$$ Could this loop be replaced by some range > method? > > Actually it does not work. I was not paying attention. It rounded > everything off, but only because it rounded off the first cell in the range > and then somehow set every other cell in the range to that same value. So > my entire range has one identical value. > > On Wed, Apr 11, 2012 at 12:45 AM, Rajan_Verma <rajanverma1...@gmail.com> > wrote: >> Yes you were right, But now you also believe that it is most efficient >> way to complete task and avoid loop. :) >> >> Thanks >> Rajan. >> >> -----Original Message----- >> From: excel-macros@googlegroups.com >> [mailto:excel-macros@googlegroups.com] >> On Behalf Of Domain Admin >> Sent: Apr/Wed/2012 02:36 >> To: excel-macros@googlegroups.com >> Subject: Re: $$Excel-Macros$$ Could this loop be replaced by some >> range method? >> >> Rajan the evaluate method did turn out to be the most efficient of the >> 3 methods I tried by a wide margin. >> >> Here is the code used which took only 13.7% of the time of the next >> best method and only 11.6% of the loop method. Pretty much as you >> described it but the Len funtion is not needed. I believe that is >> only to weed out empty cells but I could be wrong about that. >> >> With Sheets(RawData) >> Set tmprange = Range(.Cells(2, BarOpen), .Cells(stoprawdata, >> StopCol)) >> tmprange.Value = .Evaluate("round(" & tmprange.Address & >> ",2)") 'use evaluate instead of code below >> End With >> >> >> On Mon, Apr 9, 2012 at 5:51 AM, Rajan_Verma <rajanverma1...@gmail.com> >> wrote: >>> If range have only numeric value then you can use this to avoid loops : >>> >>> >>> >>> Not tested: but I think it will work >>> >>> Range.value=Evaluate(“=if(Len(“ & Range.address & “)>0,Round(“ & >>> Range.address &”,2),””)”) >>> >>> >>> >>> Rajan >>> >>> >>> >>> From: excel-macros@googlegroups.com >>> [mailto:excel-macros@googlegroups.com] >>> On Behalf Of tangledweb >>> Sent: Apr/Mon/2012 04:12 >>> To: excel-macros@googlegroups.com >>> Subject: $$Excel-Macros$$ Could this loop be replaced by some range >> method? >>> >>> >>> >>> I am trying to get more used to using ranges instead of addressing >>> individual cells by indexes. The loop below is rounding off the >>> entries in all the columns >>> >>> where BarOpen for example is just the column index in the sheet. Is >>> there a way to do this more efficiently by using the used range >>> portion of each column? >>> >>> In this case all the columns are the same length. >>> >>> >>> >>> >>> >>> ' Round off the raw data values >>> With Sheets(RawData) >>> For index = startrawdata To stoprawdata >>> Cells(index, BarOpen).Value = >>> WorksheetFunction.Round(.Cells(index, BarOpen).Value, 2) >>> Cells(index, BarHigh).Value = >>> WorksheetFunction.Round(.Cells(index, BarHigh).Value, 2) >>> Cells(index, BarLow).Value = >>> WorksheetFunction.Round(.Cells(index, BarLow).Value, 2) >>> Cells(index, BarClose).Value = >>> WorksheetFunction.Round(.Cells(index, BarClose).Value, 2) >>> Cells(index, StopCol).Value = >>> WorksheetFunction.Round(.Cells(index, StopCol).Value, 2) >>> Next index >>> 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