[英]Excel export ; using VBA, how to export cell as formatted rather than the raw cell value
This link shows how to write a small program to surround the cell value in double-quotation marks for a CSV export. 此链接显示了如何编写一个小程序以将单元格值括在双引号中以进行CSV导出。
' Write current cell's text to file with quotation marks.
Print #FileNum, """" & Selection.Cells(RowCount, _
ColumnCount).Text & """";
Is there a way to reference the cell's formatted value and write the formatted value out instead? 有没有办法引用单元格的格式化值并写出格式化值呢?
For example, the raw data could be 8543
but the spreadsheet might have Zip Code formatting applied to the column, so the value is displayed as 08543
. 例如,原始数据可能是
8543
但是电子表格可能已对该列应用了邮政编码格式,因此该值显示为08543
。
做这样的事情-获取值,然后根据所选范围的数字格式对其进行格式化:
Format(Range("A1").Value, Range("A1").NumberFormat)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.