VBA version of this front-of-house formula to make workbook less heavy

RoseG

New Member
Joined
Dec 14, 2010
Messages
14
Hey all,

Could anyone possibly advise if there is some VBA version of the following formula, that I could use. My workbook is all slow and sluggish because this thing is so bluberous.

=IF(AND(B4<>"",(SUMPRODUCT(--($B$4:B4=B4),(--($D$4:D4=D4)),(--($S$4:S4=S4))))<=1,(SUMPRODUCT(--(B4:$B$2000=B4),(--(D4:$D$2000=D4)),(--(S4:$S$2000=S4))))>1),SUMPRODUCT((B4:$B$2000=B4)*(D4:$D$2000=D4)*(S4:$S$2000=S4),(AF4:$AF$2000)),"")

Key information:
Column B is a date
Column D is a name
Column S is a location
Column AF is an ammount of time

I want to count up the ammount of time that the same person went to the same place on the same day and enter this info in column AN, on the first row of this set.

What I want Excel to do is:

Look in Columns B, D and S to see if there are duplicated entries e.g.
B1=14/04/2011, D1=John Wayne and S1=South Library
B2=15/04/2011, D2=John Wayne and S2=South Library
B3=14/04/2011, D3=John Wayne and S3=South Library

Row 1 and 3 are a match. No other matches.

Then I want it to add up the total ammount of time from column AF and enter this in column AN on the first row of the matching rows.
In the example given, this would be row 1. No entry to appear in rows 2 or 3.

Oh and I don't want Excel giving me any of its lip if no info has been entered yet. Hence the condition of B<>"" in the formula.

Is there anyone who can help?

Rose xxxx
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
You would almost certainly be better off adding a new key column that concatenates columns B, D and S, and you can then use SUMIF/COUNTIF which will be a lot more efficient.
 
Upvote 0
Top banana!

No more sluggish worksheet with this new improved fromula:

=IF(AND(COUNTIF(AN13:$AN$2000,AN13)>1,COUNTIF($AN$4:AN13,AN13)=1),SUMIF(AN13:$AN$2000,AN13,AF13:$AF$2000),"")

Might even slim it down with a SUMPRODUCT if I can figure out how.

Thanks so much!
 
Upvote 0
Hey all,

Sorry to bug with an old issue but, now I've filled in the rest of my sheet, the Concatenate solution is still slowing the book down something chronic.

Any further suggestions? I'd really appreciate it.

Thanks muchly!
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,393
Members
449,081
Latest member
JAMES KECULAH

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