We prepared vertically aligned nitrogen doped carbon nanotubes (CNTs) on a rigid glass substrate or flexible plastic substrate via a 'growth-detachment-transfer' process and the vertically aligned N-doped CNT arrays are employed as counter electrodes for novel dye-sensitized solar cells.