使用宏将数字格式转换为Excel中的文本 [英] use macro to convert number format to text in Excel

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

问题描述

我在Excel中创建了一个宏,用于将列号格式转换为文本,因此数字格式在从文本文件复制/过去之后不会更改:

I'ved created a macro in Excel that I use to convert column number format to Text so the number format does not change after copy/past from a text file:

Sub ConvertBitColumn()
' ConvertBitColumn Macro
' This macro converts 3rd column of the worksheet to Text.
Dim sht As Worksheet
Set sht = ActiveSheet
sht.Columns(2).NumberFormat = "@"
End Sub

代码工作正常,但questin中的列在某些单元格的左侧显示一些绿色,有没有办法摆脱它,或者这是正常的?感谢您的回应。

The code works fine, but the column in questin shows some green at the left hand corner for some cells, is there a way to get rid of it, or it is normal? Thanks for responding.

Amy

推荐答案

单元格有一个以文本形式存储的数字。 Excel是警告你,你不能对格式化为文本单元格的数字做数学公式。因为它听起来像你真的想要数字作为基于你的宏的文本,你可以关闭在Excel中的错误检查,摆脱那些讨厌的绿色三角形:

The green triangle indicates that the cell has a number that's stored as text. Excel is warning you that you can't do math formulas on numbers that are formatted as text cells. Since it sounds like you actually want numbers as text based on your macro, you can turn off error checking in Excel to get rid of those pesky green triangles:


  1. 单击文件选项卡。

  2. 在帮助下,单击选项。
  3. 在Excel选项对话框中,单击公式 / li>
  4. 点击错误检查规则,清除格式设置为文本的数字或在撇号前加上复选框。
  5. 单击确定。 b
  1. Click the File tab.
  2. Under Help, click Options.
  3. In the Excel Options dialog box, click the Formulas category.
  4. Under Error checking rules, clear the Numbers formatted as text or preceded by an apostrophe check box.
  5. Click OK.

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

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