将数字(非货币)值转换为文本条目

发布于 2024-12-06 02:21:17 字数 156 浏览 4 评论 0原文

概念很简单,但我不知道在创建 UDF 时从哪里开始,这是我唯一能找到的提及。我有一列在源表上填充 1 或 2。我想做一些事情,以便所有“1”显示为一个文本条目(例如“AA”),而所有“2”显示为不同的文本条目条目(说“BB”)。如果没有 UDF,这可能吗?如果没有,那么有什么建议可以从哪里开始吗?

Easy enough concept, but I have no idea where to start when it comes to creating a UDF, which is the only thing I can find any mention of. I have a column that populates on source sheets with either a 1 or 2. I want to do something so that all of the "1's" shows as one text entry("AA" for example) and all "2's" show as a different entry(say "BB"). Is this possible without a UDF; and if not then is there any advice on where to start?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

迷乱花海 2024-12-13 02:21:17

您可以为此使用自定义格式。右键单击相关列并选择“设置单元格格式”。在对话框中,选择“自定义”,然后在顶部的框中输入:

[=1]"AA";[=2]"BB";General

这假定“1”或“2”是单元格的唯一内容。任何其他数字或文本将以常规格式显示。

You can use custom formatting for this. Right-click the column in question and choose "Format Cells." In the dialog, choose "Custom" and in the box at the top enter:

[=1]"AA";[=2]"BB";General

This assumes that the "1" or "2" is the sole content of the cell. Any other number or text will display in the General format.

你对谁都笑 2024-12-13 02:21:17

这也可能对您有帮助。它是一个条件语句,将引用一个单元格,检查是否有内容,如果没有,则将放入“无”一词,否则将放入单元格的内容。

=IF((工作表 1!J1089)="","无",工作表 1!J1089)

This may help you as well. It is a conditional statement that will reference one cell the check if there is content, if not then it will put the word "None" in, otherwise it will put the contents of the cell.

=IF((Sheet1!J1089)="","None",Sheet1!J1089)

人事已非 2024-12-13 02:21:17

只是为了更新其他可能感兴趣的人。我有一个正在使用的解决方案。必须走vba路线,但我已经设置了它,以便我的运行报告的宏运行以下内容:

Sub Conversion()
  Dim X As Long, DBCodes() As String
  DBCodes = Split("AA,BB,CC", ",")
  For X = 1 To 3
    Columns("H").Replace X, DBCodes(X - 1), xlWhole
  Next
End Sub

我可以更改分割值和后面的行,以获取需要替换的更多值,尽管这需要摆弄以找到太多值会使其不切实际的点。而且,我在运行这个程序时输入的行会产生很大的不同;不过,找到了最佳位置,即使是 600 多行的报告,转换也只增加了几秒钟。

Just to update anyone else that may be interested. I have a solution that I am using. Had to go the vba route, but I've got it set up so that my macro for running reports runs the following:

Sub Conversion()
  Dim X As Long, DBCodes() As String
  DBCodes = Split("AA,BB,CC", ",")
  For X = 1 To 3
    Columns("H").Replace X, DBCodes(X - 1), xlWhole
  Next
End Sub

I can change the split values and the line after for as many more values as I need replacing, though it would take fiddling with to find the point where too many values would make it impractical. Also, it makes a world of difference where I put in the line to run this; found the best spot though and even the reports that are 600+ rows the conversion only adds a couple seconds.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文