1

我发现这个公式可以将金额转换为单词,但它不能 100% 起作用。每当金额以 20,30, 40 等结尾时,都会出现错误。例如 1020 会出错,但 1019 和 1021 可以正常工作。我试图自己解决这个问题,但没有运气。它必须是公式(与之交互的软件(Google Docs)无法处理 VBA 脚本。

这是公式:

=IF(H53<10^12,
    IF(INT(H53/10^9)>0,
        IF(INT(H53/10^11)>0,
            INDEX(
                {"One ","Two ","Three","Four ","Five ","Six ","Seven ","Eight ","Nine "},
                MATCH(INT(H53/10^11),{1,2,3,4,5,6,7,8,9})
            )&"Hundred ",
        "")&
        IF(MOD(INT(H53/10^9),100)<20,
            INDEX(
                {"","One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine ","Ten ",
                "Eleven ","Twelve","Thirteen","Fourteen ","Fifteen","Sixteen","Seventeen","Eighteen ","Nineteen"},
                MATCH(MOD(INT(H53/10^9),100),{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19})
            ),
            INDEX(
                {"","Twenty ","Thirty ","Fourty ","Fifty ","Sixty ","Seventy ","Eighty ","Ninety "}, 
                MATCH(INT(MOD(INT(H53/10^9),100)/10),{1,2,3,4,5,6,7,8,9})
            )&
            INDEX(
                {"One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine "}, 
                MATCH(MOD(INT(H53/10^9),10),{1,2,3,4,5,6,7,8,9})
            )
        )&" Billion  ",
        ""
    )&
    IF(MOD(INT(H53/10^6),10^3)>0,
        IF(INT(MOD(INT(H53/10^6),10^3)/100)>0,
            INDEX(
                {"One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine "},
                MATCH(INT(MOD(INT(H53/10^6),10^3)/100),{1,2,3,4,5,6,7,8,9})
            )&"Hundred ",
        "")&
        IF(MOD(INT(H53/10^6),100)<20,
            INDEX(
                {"","One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine ","Ten ",
                "Eleven ","Twelve","Thirteen","Fourteen ","Fifteen ","Sixteen","Seventeen","Eighteen ","Nineteen"},
                MATCH(MOD(INT(H53/10^6),100),{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19})
            ),
            INDEX(
                {"","Twenty ","Thirty ","Fourty ","Fifty ","Sixty ","Seventy ","Eighty ","Ninety "},
                MATCH(INT(MOD(INT(H53/10^6),100)/10),{1,2,3,4,5,6,7,8,9})
            )&
            INDEX(
                {"One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine "}, 
                MATCH(MOD(INT(H53/10^6),10),{1,2,3,4,5,6,7,8,9})
            )
        )&" Million  ",
        ""
    )&
    IF(MOD(INT(H53/10^3),10^3)>0,
        IF(INT(MOD(INT(H53/10^3),10^3)/100)>0,
            INDEX(
                {"One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine "},
                MATCH(INT(MOD(INT(H53/10^3),10^3)/100),{1,2,3,4,5,6,7,8,9})
            )&"Hundred ",
        "")&
        IF(MOD(INT(H53/10^3),100)<20,
            INDEX(
                {"","One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine ","Ten ",
                "Eleven ","Twelve","Thirteen","Fourteen ","Fifteen ","Sixteen","Seventeen","Eighteen ","Nineteen"},
                MATCH(MOD(INT(H53/10^3),100),{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19})
            ),
            INDEX(
                {"","Twenty ","Thirty ","Fourty ","Fifty ","Sixty ","Seventy ","Eighty ","Ninety "},
                MATCH(INT(MOD(INT(H53/10^3),100)/10),{1,2,3,4,5,6,7,8,9})
            )&
            INDEX(
                {"One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine "},
                MATCH(MOD(INT(H53/10^3),10),{1,2,3,4,5,6,7,8,9})
            )
        )&" Thousand  ",
        ""
    )&
    IF(MOD(MOD(H53,10^4),10^3)>0,
        IF(INT(MOD(MOD(H53,10^4),10^3)/100)>0,
            INDEX(
                {"One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine "},
                MATCH(INT(MOD(MOD(H53,10^4),10^3)/100),{1,2,3,4,5,6,7,8,9})
            )&"Hundred ",
            ""
        )&
        IF(MOD(MOD(MOD(H53,10^4),10^3),100)<20,
            INDEX(
                {"","One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine ","Ten ",
                "Eleven ","Twelve","Thirteen","Fourteen ","Fifteen ","Sixteen","Seventeen","Eighteen ","Nineteen"},
                MATCH(MOD(MOD(MOD(H53,10^4),10^3),100),{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19})
            ),
            INDEX(
                {"","Twenty ","Thirty ","Fourty ","Fifty ","Sixty ","Seventy ","Eighty ","Ninety "},
                MATCH(INT(MOD(MOD(MOD(H53,10^4),10^3),100)/10),{1,2,3,4,5,6,7,8,9})
            )&
            INDEX(
                {"One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine "},
                MATCH(MOD(MOD(MOD(H53,10^4),10^3),10),{1,2,3,4,5,6,7,8,9})
            )
        ),
        ""
    ),
    ""
) & " Rands"
4

1 回答 1

3

问题出在最后一部分:

 INDEX({"One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine "},
     MATCH(MOD(MOD(MOD(H53,10^4),10^3),10),{1,2,3,4,5,6,7,8,9})

MOD(MOD(MOD(H53,10^4),10^3),10)会返回0,在1-9中找不到。

因此,上述行应修改为:

 INDEX({"", "One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine "},
     MATCH(MOD(MOD(MOD(H53,10^4),10^3),10),{0, 1,2,3,4,5,6,7,8,9})

这个问题也存在于公式的其他领域。

所有在这个完整的公式中都是固定的(它还添加了一些不一致地遗漏的空格):

=IF(B1<10^12,
 IF(INT(B1/10^9)>0,
  IF(INT(B1/10^11)>0,
   INDEX(
    {"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine "},
    MATCH(INT(B1/10^11),{1;2;3;4;5;6;7;8;9})
   )&"Hundred ",
  "")&
  IF(MOD(INT(B1/10^9),100)<20,
   INDEX(
    {"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine ";"Ten ";"Eleven ";"Twelve ";"Thirteen ";"Fourteen ";"Fifteen ";"Sixteen ";"Seventeen ";"Eighteen ";"Nineteen "},
    MATCH(MOD(INT(B1/10^9),100),{0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19})
   ),
   INDEX(
    {"";"Twenty ";"Thirty ";"Fourty ";"Fifty ";"Sixty ";"Seventy ";"Eighty ";"Ninety "},
    MATCH(INT(MOD(INT(B1/10^9),100)/10),{1;2;3;4;5;6;7;8;9})
   )&
   INDEX(
    {"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine "},
    MATCH(MOD(INT(B1/10^9),10),{0;1;2;3;4;5;6;7;8;9})
   )
  )&" Billion  ",
  ""
 )&
 IF(MOD(INT(B1/10^6),10^3)>0,
  IF(INT(MOD(INT(B1/10^6),10^3)/100)>0,
   INDEX(
    {"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine "},
    MATCH(INT(MOD(INT(B1/10^6),10^3)/100),{0;1;2;3;4;5;6;7;8;9})
   )&"Hundred ",
  "")&
  IF(MOD(INT(B1/10^6),100)<20,
   INDEX(
   {"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine ";"Ten ";"Eleven ";"Twelve ";"Thirteen ";"Fourteen ";"Fifteen ";"Sixteen ";"Seventeen ";"Eighteen ";"Nineteen "},
    MATCH(MOD(INT(B1/10^6),100),{0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19})
   ),
   INDEX(
    {"";"Twenty ";"Thirty ";"Fourty ";"Fifty ";"Sixty ";"Seventy ";"Eighty ";"Ninety "},
    MATCH(INT(MOD(INT(B1/10^6),100)/10),{1;2;3;4;5;6;7;8;9})
   )&
   INDEX(
    {"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine "},
    MATCH(MOD(INT(B1/10^6),10),{0;1;2;3;4;5;6;7;8;9})
   )
  )&" Million  ",
  ""
 )&
 IF(MOD(INT(B1/10^3),10^3)>0,
  IF(INT(MOD(INT(B1/10^3),10^3)/100)>0,
   INDEX(
    {"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine "},
    MATCH(INT(MOD(INT(B1/10^3),10^3)/100),{0;1;2;3;4;5;6;7;8;9})
   )&"Hundred ",
  "")&
  IF(MOD(INT(B1/10^3),100)<20,
   INDEX(
    {"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine ";"Ten ";"Eleven ";"Twelve ";"Thirteen ";"Fourteen ";"Fifteen ";"Sixteen ";"Seventeen ";"Eighteen ";"Nineteen "},
    MATCH(MOD(INT(B1/10^3),100),{0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19})
   ),
   INDEX(
    {"";"Twenty ";"Thirty ";"Fourty ";"Fifty ";"Sixty ";"Seventy ";"Eighty ";"Ninety "},
    MATCH(INT(MOD(INT(B1/10^3),100)/10),{1;2;3;4;5;6;7;8;9})
   )&
   INDEX(
    {"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine "},
    MATCH(MOD(INT(B1/10^3),10),{0;1;2;3;4;5;6;7;8;9})
   )
  )&" Thousand  ",
  ""
 )&
 IF(MOD(MOD(B1,10^4),10^3)>0,
  IF(INT(MOD(MOD(B1,10^4),10^3)/100)>0,
   INDEX(
    {"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine "},
    MATCH(INT(MOD(MOD(B1,10^4),10^3)/100),{0;1;2;3;4;5;6;7;8;9})
   )&"Hundred ",
   ""
  )&
  IF(MOD(MOD(MOD(B1,10^4),10^3),100)<20,
   INDEX(
    {"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine ";"Ten ";"Eleven ";"Twelve ";"Thirteen ";"Fourteen ";"Fifteen ";"Sixteen ";"Seventeen ";"Eighteen ";"Nineteen "},
    MATCH(MOD(MOD(MOD(B1,10^4),10^3),100),{0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19})
   ),
   INDEX(
    {"";"Twenty ";"Thirty ";"Fourty ";"Fifty ";"Sixty ";"Seventy ";"Eighty ";"Ninety "},
    MATCH(INT(MOD(MOD(MOD(B1,10^4),10^3),100)/10),{1;2;3;4;5;6;7;8;9})
   )&
   INDEX(
    {"";"One ";"Two ";"Three ";"Four ";"Five ";"Six ";"Seven ";"Eight ";"Nine "},
    MATCH(MOD(MOD(MOD(B1,10^4),10^3),10),{0;1;2;3;4;5;6;7;8;9})
   )
  ),
  ""
 ),
 ""
) & " Rands"
于 2013-02-25T12:17:13.263 回答