You can't have a function/sub nested within another. Notice that your End If belongs outside of the function.
Sub Check3sec()
Dim rownumber As Integer
rownumber = ActiveCell.Row
If ActiveCell.Value <> "" Then
Function MinValue()
Range("B6") = WorksheetFunction.Min(Range("rownumber:rownumber+60"))
End If
End Function
End Sub
Option Explicit
Sub Check3sec()
Dim rownumber As Long
Dim myMin
rownumber = ActiveCell.Row
If ActiveCell.Value <> "" Then
myMin = MinValue(rownumber) ' <<<<--call a function/sub from within another passing the value to process
Range("B6").Value = myMin
End If
End Sub
Function MinValue(ByVal RNum As Double) As Double
MinValue = WorksheetFunction.Min(Range(RNum & ":" & RNum + 60)) ' <<----- Return the MIN to the calling sub
End Function
Bookmarks