增量编号以及Google表上的日期

发布于 2025-02-13 18:50:58 字数 395 浏览 2 评论 0原文

我想将列中的单元格增加1到999。事实是,它包含一个数字和日期:

1
001/2022
002/2022
003/2022
...
999/2022

项目 这样吗?我认为可以将日期“硬代码”为字符串“ 2022”,并在其旁边递增值,但是是否可以维护日期格式?如果有人可以提供两个答案以及如何以各种方式解决它们,我将是很多义务。抱歉,如果有这样的提及,我只是找不到。我是新手。

I would like to increment a cell in a column by 1 to 999. The thing is, it contains both a number and a date:

Item 1
001/2022
002/2022
003/2022
...
999/2022

Is there a way to do this? I assume it's possible to "hard code" the date as a string "2022" and increment the value beside it but, would it be possible to maintain the date format? If anyone can provide both answers and how to tackle them in each way, I'd be much obliged. Sorry if there is a reference to something like that, I just can't find it. I'm fairly new to this.

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

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

发布评论

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

评论(2

无敌元气妹 2025-02-20 18:50:58

将其放在其下方至少998个打开单元格的任何单元格中:

= arrayformula(text(sequence(999),“ 000”)&“/2022”)>

Place this in any cell with at least 998 open cells below it:

=ArrayFormula(TEXT(SEQUENCE(999),"000")&"/2022")

煞人兵器 2025-02-20 18:50:58

您可以按“/”,Parse&递增左值,然后重新加入两个部分:

function testIncrement() {
  console.log(increment("005/2021"));
}

function increment(cellValue) {
  const DIVIDER = "/";
  let [a, b] = cellValue.split(DIVIDER)
  return `${Utilities.formatString("%03d", parseInt(a) + 1)}${DIVIDER}${b}`;
}

You could split the string by "/", parse & increment the left value and then rejoin the two parts like so:

function testIncrement() {
  console.log(increment("005/2021"));
}

function increment(cellValue) {
  const DIVIDER = "/";
  let [a, b] = cellValue.split(DIVIDER)
  return `${Utilities.formatString("%03d", parseInt(a) + 1)}${DIVIDER}${b}`;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文