averyww
October 6th, 1999, 01:29 PM
I am programming Excel for a friend and need to iterate through all of the worksheets to check for a condition ( to determine if a date matches - the date is in a certain cell - the user enters the date required to match). I have tried every kind of flow statement, hoeveer, I feel the the For each sheet ..... Next sheet should do it and it doesn't. Here is the code
[
Dim visit_date As Date
Dim F As String
Dim sheet As Worksheet
' nurse enters visit date to search
visit_date = InputBox("Enter Clinic Date:")
' check against next visit date for match
' if match, then set F as variable for next F visit
For Each sheet In Workbooks("l_soca.xls").Worksheets
If Range("A5").Value = visit_date Then
F = Range("B5").Value
lots more cled
End If
Next sheet
End Sub]
What am I doing wrong?
thank you in advance, gerry
[
Dim visit_date As Date
Dim F As String
Dim sheet As Worksheet
' nurse enters visit date to search
visit_date = InputBox("Enter Clinic Date:")
' check against next visit date for match
' if match, then set F as variable for next F visit
For Each sheet In Workbooks("l_soca.xls").Worksheets
If Range("A5").Value = visit_date Then
F = Range("B5").Value
lots more cled
End If
Next sheet
End Sub]
What am I doing wrong?
thank you in advance, gerry