Terribly slow UDF similar to CONCATENATE IF

MAXARN

New Member
Joined
Jul 8, 2011
Messages
26
Hey again,

I modified an UDF I found somewhere so it works for me, the problem is that it's so CPU intensive that just using it once makes excel work for 3-6 seconds when I edit any cell.

All it does is look at a column and copy text when a criteria is met on a different column and bunch the matches together. It goes like this:

Public Function ConcatIf(ConcatRange As Range, PID As Integer) As String
Dim rng As Range
For Each rng In ConcatRange
If rng.Offset(0, -11).Value = PID Then
ConcatIf = ConcatIf & rng.Value
End If
Next rng

End Function

Is this just the way it goes when working with strings or can something be done?

edit: I don't know that it matters, but only 9 rows contain values so far of the ~400 rows at the moment (but it's growing).
 
Last edited:

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

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