Hi,
I am trying to add all the numbers that contain A, B, C and D... (project) The cells contains a mix of number and text. I would like to add all the numbers that contain, A, B, C etc. For example the result here should Project A =1, Project B=4, Project C=2
I have tried to make a VBA function like the one shown below based on something from the web, but getting stuck.
[TABLE="width: 500"]
<tbody>[TR]
[TD]3 B
[/TD]
[/TR]
[TR]
[TD]1A
[/TD]
[/TR]
[TR]
[TD]1B
[/TD]
[/TR]
[TR]
[TD]2 C
[/TD]
[/TR]
</tbody>[/TABLE]
Function CountProject(range_data As Range, criteria As Range) As Double
Dim datax As Range
Dim project As Double
project = criteria.text
CountProject = 0
For Each datax In range_data
If datax.text = project Then
ProjectCount = ProjectCount + Val(datax)
End If
Next datax
End Function
Please let me know if there is an elegant way to make this function work.
Thanks
Alan
I am trying to add all the numbers that contain A, B, C and D... (project) The cells contains a mix of number and text. I would like to add all the numbers that contain, A, B, C etc. For example the result here should Project A =1, Project B=4, Project C=2
I have tried to make a VBA function like the one shown below based on something from the web, but getting stuck.
[TABLE="width: 500"]
<tbody>[TR]
[TD]3 B
[/TD]
[/TR]
[TR]
[TD]1A
[/TD]
[/TR]
[TR]
[TD]1B
[/TD]
[/TR]
[TR]
[TD]2 C
[/TD]
[/TR]
</tbody>[/TABLE]
Function CountProject(range_data As Range, criteria As Range) As Double
Dim datax As Range
Dim project As Double
project = criteria.text
CountProject = 0
For Each datax In range_data
If datax.text = project Then
ProjectCount = ProjectCount + Val(datax)
End If
Next datax
End Function
Please let me know if there is an elegant way to make this function work.
Thanks
Alan