For i:= 0 To StringGrid1.ColCount - 1 Do For j:= 0 To StringGrid1.RowCount - 1 Do if StringGrid1.Cells[i,j] = '' Then StringGrid1.Cells[i,j]:= '0';