View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JMCN JMCN is offline
external usenet poster
 
Posts: 14
Default excel 97: if then and for next loops help

"Tom Ogilvy" wrote in message A more compact way of doing this is:

Sub Finish_Click()
Dim bFail As Boolean
Dim cell As Range

For Each cell In Range("C27:C46,C52:C70")
If cell.Value < 0 Then
If Not IsDate(cell.Offset(0, -1)) Then
cell.Offset(0, -1).Value = "Missing tx Date"
bFail = True
End If
End If
If cell.Offset(0, 4).Value < 0 Then
If Not IsDate(cell.Offset(0, 3)) Then
cell.Offset(0, 3).Value = "Missing tx Date"
bFail = True
End If
End If
Next
If bFail Then
MsgBox "Dates are Missing"
Else
MsgBox "Finished"
End If
End Sub

thanks for your help tom! i always get lost in the for next and if
then statements! jung