Attribute VB_Name = "ReadStockCode" Option Explicit Function run(row As Integer) On Error GoTo eh Dim temp As String temp = Worksheets(TARGET_SHEET).Range(COL_STOCK_CODE & CStr(row)).Value If (temp = "") Then temp = -1 End If run = temp Done: Exit Function eh: Debug.Print "ReadStockCode" Debug.Print row Debug.Print temp End Function