I m using vba codes to generate reports from excel to word and I am getting stuck. The number I am copying seems to not have the format from excel, I need it to be formatted into currency ie $1,000 or $5,212,345 and right now it just showing as 1000 and 5212345.
Here is my codes, I have a method or data member not found error.
.TypeText "Total Written Premium: " & ws4.Range("I" & LR12)
.Format (ws4.Range("I" & LR12) = "$#,##0.00_)")
.TypeText "Total Written Premium: " & ws4.Range("I" & LR12)
You're fetching the Range
's Value
, implicitly. This would be more explicit:
.TypeText "Total Written Premium: " & ws4.Range("I" & LR12).Value
A cell's value doesn't have any formatting. It's not a representation of the underlying value, it's the value itself .
If the cell is already formatted as currency then you need to get its Text
instead:
.TypeText "Total Written Premium: " & ws4.Range("I" & LR12).Text
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.