在Microsoft Excel中格式化幻想货币时,如何解决误解?

发布于 2025-02-01 04:55:53 字数 1456 浏览 2 评论 0 原文

我正在尝试为我的D& d幻想货币设置Excel。

我想使用Excel将整数和小数转换为黄金(GP),银(SP)和铜(CP)件;例如25.47 = 25GP 4SP 7CP。


转换非常简单,如在此转换表上或下面看到的那样。

1Sp = 10cp

1gp = 10sp = 100cp


i从答案中获得此代码,该答案 user4039065 juddson ivines - 如何以microsoft excel中的幻想货币格式化

? ;;;“)& text( - 右(text(j6,“ 0.0”)),“ 0 \ s \ p ;;;”) ),“ 0 \ c \ p ;;”))


乍一看,此代码效果令人惊讶。

但是,在将0.6转换为6CP时,代码弄乱并回答为 1cp 6sp 。由于某种原因,代码正在添加1Sp。

我什至从1CP到超过2GP播放以检查错误,您可以请参阅此处。这就是我遇到0.95错误的方式。



感谢 user4039065 的答案和开始代码,以及 提出原始问题。



很抱歉在这里成为新手,而且我无法嵌入我的图像。

我真的很感谢您纠正此代码格式的一些帮助。

I am trying to set up Excel for my D&D Fantasy Currency.

I want to use Excel to convert integers and decimals to gold (gp), silver (sp), and copper (cp) pieces; e.g. 25.47 = 25gp 4sp 7cp.


The conversion is fairly simple, as seen on this conversion table or below.

enter image description here

1sp = 10cp

1gp = 10sp = 100cp


I got this code from an answer that user4039065 posted on as similar question asked by Juddson Ivines - How to format fantasy currency in Microsoft Excel?:

=TRIM(TEXT(INT(J6),"0 \g\p ;;;")&TEXT(--RIGHT(TEXT(J6,"0.0")),"0 \s\p ;;;")&TEXT(--RIGHT(TEXT(J6,"0.00")),"0 \c\p ;;;"))


This code at first glance worked amazingly.

However when it came to converting 0.6 to 6cp, the code messes up and answers as 1cp 6sp. For some reason the code is adding 1sp.

A further error occurs at 0.95-0.99, where it drops the 9sp entirely.

I even gridded out from 1cp to over 2gp to check for errors, which you can see here, which is how I caught the 0.95 error.



Thanks to user4039065 for their answer and starting code, as well as Juddson Ivines for asking the original question.



Apologies for being new here and my lack of being able to embed my images.

I would really appreciate some help with correcting the format of this code.

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

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

发布评论

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

评论(1

浮华 2025-02-08 04:55:53

C列中的公式为:

=TRIM(IF(B5>=1;INT(B5)&"gp ";"")&IF(B5-INT(B5)>=0,1;MID(B5-INT(B5);3;1)&"sp ";"")&IF(LEN(B5-INT(B5))>3;VALUE(MID(B5-INT(B5);4;2))&"cp";""))

您可能会从几个功能中受益。棘手的部分是获得每种类型的硬币的IF,并且还避免铜硬币中的左零(这是价值义务)

有时您可能会因小数而获得怪异的输出。您只需要将值弄圆。

enter image description here

Formula in column C is:

=TRIM(IF(B5>=1;INT(B5)&"gp ";"")&IF(B5-INT(B5)>=0,1;MID(B5-INT(B5);3;1)&"sp ";"")&IF(LEN(B5-INT(B5))>3;VALUE(MID(B5-INT(B5);4;2))&"cp";""))

You may benefit from several functions to achieve this. The tricky part is to get an IF for each type of coin and also avoid left zeros in the copper coins (that's the VALUE duty)

Probably sometimes you may get weird output due to decimals. You just need to Round the values.

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