Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default How to speed up this macro?

Ctech,

This code:

Range("A2").FormulaR1C1 = _
"=IF(SUMIF(C[9],RC[9],C[10])=0,""SortLow"",""SortHigh"")"

C[9] means 9 columns to the right of the current column (A), so C[9] = J:J, C[10] = K:K

Creates this formula:

=IF(SUMIF(J:J,J2,K:K)=0,"SortLow","SortHigh")

This part

SUMIF(J:J,J2,K:K)

returns the sum from column K (Your initial column J) where the value in column J (your initial
column I) is the same as that of the current row.

Lets say that column J and K has these values

Bernie 5
Ctech 4
Fred 0
Bernie 6
Ctech 4
Fred 0

The SUMIF would return values like this:

11 Bernie 5
8 Ctech 4
0 Fred 0
11 Bernie 6
8 Ctech 4
0 Fred 0

But the IF function would change those to

SortHigh Bernie 5
SortHigh Ctech 4
SortLow Fred 0
SortHigh Bernie 6
SortHigh Ctech 4
SortLow Fred 0

Which, when sorted, would be

SortHigh Bernie 5
SortHigh Ctech 4
SortHigh Bernie 6
SortHigh Ctech 4
SortLow Fred 0
SortLow Fred 0

Then the bottom two rows would be deleted.

HTH,
Bernie
MS Excel MVP


"Ctech" wrote in message
...

This helped a lot, however I don't understand how this code

Range("A2").FormulaR1C1 = _
"=IF(SUMIF(C[9],RC[9],C[10])=0,""SortLow"",""SortHigh"")"

works

I guess:
C=[9] = Column 9 from A ("I:I" - Cost center column)
RC[9] = Cell 9 from A ("I?" - Cost center)
C[10] = Column 10 from A ("J:J" - Supplier column)

How does this Sum column K (Func_Value coulmn)?

Could you explain this, even more? I have read the SUMIF help on Excel,
however it didn't help much.


Thanks so far for all the help.


--
Ctech
------------------------------------------------------------------------
Ctech's Profile: http://www.excelforum.com/member.php...o&userid=27745
View this thread: http://www.excelforum.com/showthread...hreadid=472537



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
Help, need to speed up this macro retseort Excel Discussion (Misc queries) 3 January 12th 06 12:33 PM
Macro Speed Don Lloyd Excel Programming 4 July 28th 05 06:02 PM
Speed-up a macro! maca[_3_] Excel Programming 3 July 15th 05 06:40 PM
Speed up macro rn Excel Discussion (Misc queries) 3 February 21st 05 01:25 PM
Using With to speed up macro Wesley[_2_] Excel Programming 2 December 30th 03 10:54 AM


All times are GMT +1. The time now is 03:55 PM.

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

About Us

"It's about Microsoft Excel"