Your code isn't working the way you think it is. Try putting the
entire IF statement on a single line of code:
If (r.Value = "06-00 Sunrise SEVEN Perth_Hits") Then ret = 131
Of, better, use a Select Case statement
Select Case r.Value
Case "06-00 Sunrise SEVEN Perth_Hits"
ret = 131
Case "06-00 Sunrise SEVEN Melbourne_Hits"
ret = 131
' rest of your Case statement
End Select
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"Vlad999"
wrote in message
...
When I use the code below I get the following error message
"Compile
Error Block if Without End if" What have i done wrong?
Code:
--------------------
Function doCount(r)
Dim ret As Integer
If (r.Value = "06-00 Sunrise SEVEN Perth_Hits") Then
ret = 131
If (r.Value = "06-00 Sunrise SEVEN Melbourne_Hits") Then
ret = 131
If (r.Value = "06-00 Sunrise SEVEN Brisbane_Hits") Then
ret = 131
If (r.Value = "06-00 Sunrise SEVEN Adelaide_Hits") Then
ret = 131
If (r.Value = "06-00 Ten Early News TEN Sydney_Hits") Then
ret = 40
If (r.Value = "06-00 Ten Early News TEN Brisbane_Hits") Then
ret = 40
If (r.Value = "06-00 Ten Early News TEN Melbourne_Hits") Then
ret = 40
If (r.Value = "06-00 Ten Early News TEN Perth_Hits") Then
ret = 40
If (r.Value = "06-00 Ten Early News TEN Adelaide_Hits") Then
ret = 40
If (r.Value = "06-00 Today NINE Sydney_Hits") Then
ret = 110
If (r.Value = "06-00 Today NINE Melbourne_Hits") Then
ret = 110
If (r.Value = "06-00 Today NINE Brisbane_Hits") Then
ret = 110
If (r.Value = "06-00 Today NINE Adelaide_Hits") Then
ret = 110
If (r.Value = "06-00 Today NINE Perth_Hits") Then
ret = 110
If (r.Value = "17-00 Ten News TEN Sydney_Hits") Then
ret = 120
If (r.Value = "17-00 Ten News TEN Melbourne_Hits") Then
ret = 97
If (r.Value = "17-00 Ten News TEN Brisbane_Hits") Then
ret = 70
If (r.Value = "17-00 Ten News TEN Adelaide_Hits") Then
ret = 38
If (r.Value = "17-00 Ten News TEN Perth_Hits") Then
ret = 63
If (r.Value = "17-30 Sports Tonight TEN Sydney_Hits") Then
ret = 446
If (r.Value = "17-30 Sports Tonight TEN Melbourne_Hits") Then
ret = 446
If (r.Value = "17-30 Sports Tonight TEN Brisbane_Hits") Then
ret = 446
If (r.Value = "17-30 Sports Tonight TEN Adelaide_Hits") Then
ret = 446
If (r.Value = "17-30 Sports Tonight TEN Perth_Hits") Then
ret = 446
If (r.Value = "18-00 National Nine News NINE Sydney_Hits")
Then
ret = 326
If (r.Value = "18-00 National Nine News NINE Melbourne_Hits")
Then
ret = 261
If (r.Value = "18-00 National Nine News NINE Brisbane_Hits")
Then
ret = 169
If (r.Value = "18-00 National Nine News NINE Adelaide_Hits")
Then
ret = 77
If (r.Value = "18-00 National Nine News NINE Perth_Hits") Then
ret = 75
Else
ret = 0
End If
doCount = ret
End Function
--------------------
--
Vlad999
------------------------------------------------------------------------
Vlad999's Profile:
http://www.excelforum.com/member.php...o&userid=33586
View this thread:
http://www.excelforum.com/showthread...hreadid=544111