I'm constructing a Word doc from VBA (Excel) with Excel table data. The data was placed in the table OK. The last column has numbers (e.g. 456789) That I want to number-format (e.g. $456,789).
Word adds chr(13) and chr(7) at the end of each table cell value (so that the length of the visible value 456789 is not 6 but 8).
Without the Replace statement below to eliminate these two chars I could not treat the value as a string and further manipulate.
Is this the best way vba has to offer for accessing table cells values as a standard type such as String? Why do I need to eliminate the ending chars in the process? what am I missing?
For Each cell In .Columns(3).Cells
strCellValue = CStr(cell.Range.Text)
strCellValue = Replace(strCellValue, Chr(13) & Chr(7), "")
If IsNumeric(strCellValue) Then
cell.Range.Text = Format(strCellValue, "$#,##0")
End If
Next
Thanks!