Function Count_Commas(Range, Text As String) As Integer ' Written by Barrie Davidson Dim Length As Variant Dim Counter As Integer Dim Position As Integer Dim Text_to_look_for As String Dim Text_to_compare As String Text_to_look_for = Text Length = Range.Value Length = Len(Length) Counter = 0 Position = 1 Do Until Position > Length Text_to_compare = Mid(Range.Value, Position,1) If Text_to_compare = Text_to_look_for Then Count_Commas = Count_Commas + 1 Else End If Position = Position + 1 Loop End FunctionAfter you have pasted the code, you can close the visual basic editor window (this doesn't take you out of Excel). To access this custom function, (from the top menu in Excel), select Insert|Function. The Paste Function menu box will pop up. Select User Defined in the left window and then select the function you created from the right window.
Copyright ©
2001 by Barrie R. Davidson
Added September, 2001