Excel VBA中的列types转换
我想将整列转换为types(数字)
示例在上面的图像中,一些数据是stringtypes,一些是数字types的,我希望整个列中的所有数据都是types编号。
您可以在重新input值之前将单元格格式更改为常规。
Sub tt() col = "A" lastRowIndex = Cells(Rows.Count, col).End(xlUp).Row Set c = Range(Cells(1, col), Cells(lastRowIndex, col)) c.NumberFormat = "" c.FormulaLocal = c.Value End Sub
尝试这个
Sub ShivaGupta () Columns("nameofcolumn").NumberFormat = "0.00" End Sub
如果你正在寻找一个Excel公式,你可以试试这个:
=VALUE(A1)
tombata的答案似乎是一个好方法,但是,你也可以通过for循环遍历每一个单元格的值。根据你的需要,使用CInt()或CDouble()来转换每个单元格的值。
types转换函数