View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default End Select without Select Case, Block If without End If errors

Count the "If"s and "End If"s here :

Case 1
If neighbours < liveMin Then
ConwaysStepCell = 0
If neighbours liveMax Then
ConwaysStepCell = 0
Else
ConwaysStepCell = 1
End If

Seems like you want:
Case 1
If neighbours = liveMin Then
ConwaysStepCell = 1
Else
ConwaysStepCell = 0
End If

NickHK

"Atreides" <atreides1AThotmailD0Tcom wrote in message
...
I am trying to implement the function below (good computer scientists will
know why =)). However I keep getting the following errors:

"End Select without Select Case"

If I try moving the tabs around, I sometimes get the following error:

"Block If without End If"

However, these error messages don't seem to make sense as everything is
closed. How can I fix this?

Thanks
Atreides


=========
Function ConwaysStepCell(neighbours, current, newLife, liveMin, liveMax)
Select Case current
Case 0
If neighbours = newLife Then
ConwaysStepCell = 1
Else
ConwaysStepCell = 0
End If
Case 1
If neighbours < liveMin Then
ConwaysStepCell = 0
If neighbours liveMax Then
ConwaysStepCell = 0
Else
ConwaysStepCell = 1
End If
End Select
End Function