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