The Offset method would suit you better for this operation.Instead of the Do loopUseActiveCell.offset(linecnt-tempcnt,0).activate