Just learning. There is something fundamental I am misunderstanding here. Trying to search down the active column for explicitly entered "arriving" and "leaving" cells and fill in the blanks. This is a simplified special case for the top cells in a column. The cells below the top look up one row and assign a value based on that "previous" row's entry. The whole thing works, but calling the function from one cell changes other cells with that function.
Public Function Test(ByVal Previous$)
Dim searchcol As Range
Dim ArrRow As Integer
Dim LeaRow As Integer
Set searchcol = ActiveCell.Columns("A:A").EntireColumn
ArrRow = Application.Match("arriving", searchcol, 0)
LeaRow = Application.Match("leaving", searchcol, 0)
If LeaRow < ArrRow Then
Test = "Work"
Else
Test = "Home"
End If
End Function
Thank you.
Bookmarks