How to change Format of a Cell to Text using VBA

前端 未结 4 1361
一整个雨季
一整个雨季 2020-12-03 04:34

I have a "duration" column in an Excel sheet. Its cell format always changes — I want convert the duration from minutes to seconds, but because of the cell formatt

4条回答
  •  遥遥无期
    2020-12-03 04:38

    To answer your direct question, it is:

    Range("A1").NumberFormat = "@"
    

    Or

    Cells(1,1).NumberFormat = "@"
    

    However, I suggest making changing the format to what you actually want displayed. This allows you to retain the data type in the cell and easily use cell formulas to manipulate the data.

提交回复
热议问题