复制上面的单元格并将值增加 1(值按字母顺序排列)
我是 VBA 新手,需要一些帮助。从活动单元格中,我需要复制上面单元格中的值并将值加 1。该值始终是两个字母,例如 AA、AB、AC。我可以找到有关递增数字的信息,但找不到有关字母的信息。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我是 VBA 新手,需要一些帮助。从活动单元格中,我需要复制上面单元格中的值并将值加 1。该值始终是两个字母,例如 AA、AB、AC。我可以找到有关递增数字的信息,但找不到有关字母的信息。
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
应该适用于任何两个字母的组合(但“ZZ”会给你“AAA”),
没有使用范围引用的限制:
输出:
should work for any two-letter combo (but "ZZ" will give you "AAA")
Without the limitations of using range references:
Output:
字节数组方法作为启动帮助
为了艺术的目的,我演示了另一种在给定范围内从“AA”到“ZZ”“递增”两个字母组合的方法;这可以通过增加所谓的字节数组中最后一个|前一个字母的数值来完成。
将变量(例如
by()
)声明为 Byte 类型后,可以通过s
)分配给它>by = s。使用的字母(A 到 Z)现在显示元素对中相应的数字字符值(第一个字母值可以取自by(0)
,第二个=最后一个取自by (2)
或by(ubound(by)-1)
因为这里有 4 个索引为 0 到 3 的元素)。Byte array approach as start help
For the sake of the art I demonstrate another approach to "increment" a two-letter combination within a given range from "AA" to "ZZ"; this can be done by incrementing the numeric value of the last|previous letter in a so called byte array.
Having declared variable (e.g.
by()
) as of type Byte one can easily assign the string value (e.g.s
) to it viaby = s
. The used alphabetic letters (A to Z) now show the corresponding numeric character value in element pairs (the first letter value can be taken fromby(0)
, the second=last one fromby(2)
orby(ubound(by)-1)
as there are 4 elements with indices 0 to 3 here).