将存储为文本的数字转换为列中的数字 [英] Convert Number stored as Text to Number in column

查看:120
本文介绍了将存储为文本的数字转换为列中的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Excel工作表中有一列混合数据,其中数字的格式为文本".

I have a column of mixed data in my Excel sheet where the numbers are formatted as "Text".

一些例子:

  • 36
  • R4
  • 56
  • AF PL RFD
  • 65
  • DHU
  • 14

我需要将列中的所有数值转换为格式"Number",这样我就可以进一步处理数据了.

I need to convert all the numeric values in the column to the format "Number" so I can further process the data.

以下内容引发错误400,而没有任何进一步的解释:

The following throws an error 400 without any further explanation:

Sheet1.Range("A2","A50000").Select
With Selection
    .NumberFormat = "General"
    .Value = .Value
End With

我的列中没有多少行带有值,所以我不得不将范围设置得相当大.

I don't how many rows with values my column will contain so I had to make the range fairly big.

推荐答案

避免尝试在同一语句中同时选择选择工作表和范围(实际上,您可以避免完全选择):

Avoid trying to Select both a worksheet and a range in the same statement (in fact, you can avoid Select completely):

Sub ytrewq()
    With Sheet1.Range("A2", "A50000")
        .NumberFormat = "General"
        .Value = .Value
    End With
End Sub

似乎可以正常工作!

这篇关于将存储为文本的数字转换为列中的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆