Can you suggest a more efficient way of doing this in VBA?

zb134

New Member
Joined
Jun 23, 2014
Messages
38
I have a table similar to what is shown
Col A (Item)Col L (Committed Qty)Col N (Available Qty)
A52
B23
C11
A22
D14
B23
C11

<tbody>
</tbody>

What I need to do is simple, for each individual unique item (Col A)check if the Total of Col L> Total of Col N (to see if we have committed more than we have) and highlight the cell if it is.

I know how to do this using VBA my using two For loops and going through each cell in Col A and Check for a match in all other rows and then add up corresponding values in Col L and Col N.

But I have few thousand rows and this seems a very inefficient way of doing it.
Any suggestions?


Also, I know how to do this easily without VBA using sumif but that is not suited for my overall purpose.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Have you considered using a pivot table?
 
Upvote 0
Hi,

How about using Conditional Formatting with Sumif() e.g.

Code:
=SUMIF($A$2:$A$8,$A2,$B$2:$B$8)>SUMIF($A$2:$A$8,$A2,$C$2:$C$8)

Hope this helps

Eric
 
Upvote 0

Forum statistics

Threads
1,214,893
Messages
6,122,121
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top