I have had this problem before but never in something so simple. In this case it is looking at the variable DataRowCount that is defined as an Integer in the function and assigned the value of 1 in the subroutine. In the subroutine I get the Compile error and it highlights the variable. Can someone tell me why?
Function UpdateWeekDetailsSheet(ProjectName As String, FirstRowOfData As Integer, DataRowCount As Integer, FirstDateColumn As Integer)
Sheets(WeekDetails).Select
Cells.Find(What:=ProjectName, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate 'Search for the Project Name
End Function
Sub TestCall()
Dim CurRow As Integer 'Current Row is used when searching rows
DataRowCount = 1
CurRow = ActiveCell.Row
Do While Cells(ActiveCell.Row + 1, 2) <> ""
DataRowCount = DataRowCount + 1
Loop
Call UpdateWeekDetailsSheet(Cells(ActiveCell.Row - 1, 1), ActiveCell.Row, DataRowCount, ActiveCell.Column)
End Sub
Function UpdateWeekDetailsSheet(ProjectName As String, FirstRowOfData As Integer, DataRowCount As Integer, FirstDateColumn As Integer)
Sheets(WeekDetails).Select
Cells.Find(What:=ProjectName, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate 'Search for the Project Name
End Function
Sub TestCall()
Dim CurRow As Integer 'Current Row is used when searching rows
DataRowCount = 1
CurRow = ActiveCell.Row
Do While Cells(ActiveCell.Row + 1, 2) <> ""
DataRowCount = DataRowCount + 1
Loop
Call UpdateWeekDetailsSheet(Cells(ActiveCell.Row - 1, 1), ActiveCell.Row, DataRowCount, ActiveCell.Column)
End Sub