Your loop control variable (rIndex) runs from 0 to whatever. When itis 0 and is used in ...cells(rIndex,1).. it fails because there is norow 0 on a spreadsheet. Start from 1 instead.