Function getFormattedRowNumber(sheetName as string) As Integer ActiveWorkbook.Sheets(sheetName).Activate Dim c As Range For Each c In Range("A:A") If Not c.Interior.Color = 16777215 Then getFormattedRowNumber = c.Row Exit For End If If c.Value = "" Then getFormattedRowNumber = c.Row Exit For End If Next c End Function