LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default What is wrong with my UDF

I am trying to count how many in a range meet a condition. The twist
is that there is another column that the column needs to meet the
condition. I wanted it as a Function so I could show my work to
others who may have to view this. It calculates fine but then seems
to be stuck in a loop on recalculating. Any Help? Code below.

Thanks,
Jay

Function CountCondition(CntRng As Range, Cond As Double) As Variant

Dim X As Integer
Dim i
X = 0
For Each i In CntRng
If i.Offset(0, -4).Value = Cond And Right(i.Value, 4) = "2008"
Then
X = X + 1
End If
CountCondition = X
Next i

End Function
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Calculated Field (wrong Qty*Price = wrong Amount) Edmund Excel Discussion (Misc queries) 8 October 4th 07 12:13 PM
not sure what is wrong Alex H Excel Worksheet Functions 7 January 16th 07 08:27 PM
What Am I Doing Wrong comparini3000 Excel Discussion (Misc queries) 1 June 12th 06 05:51 PM
wHAT AM i DOING wrong DMB Excel Worksheet Functions 3 December 27th 05 05:41 PM
What am I doing wrong? jewels Excel Worksheet Functions 8 December 8th 05 02:04 PM


All times are GMT +1. The time now is 07:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"