How Do I Convert an Integer to a String in Excel VBA?

后端 未结 10 1765
遥遥无期
遥遥无期 2020-12-07 15:53

How do I convert the integer value \"45\" into the string value \"45\" in Excel VBA?

10条回答
  •  庸人自扰
    2020-12-07 16:36

    If the string you're pulling in happens to be a hex number such as E01, then Excel will translate it as 0 even if you use the CStr function, and even if you first deposit it in a String variable type. One way around the issue is to append ' to the beginning of the value.

    For example, when pulling values out of a Word table, and bringing them to Excel:

    strWr = "'" & WorksheetFunction.Clean(.cell(iRow, iCol).Range.Text)
    

提交回复
热议问题