用数据填充电子表格的公式

发布于 2024-12-08 18:10:18 字数 490 浏览 5 评论 0原文

我想在给定的条件下填充一些单元格。问题是,我不知道如何仅使用公式来做到这一点(不能使用宏或排序)。

无论如何,这是我的工作簿,及其**工作表**

**Sheet1**
TASK     Week
Test     1
Test2    1
Test3    1
Test4    2
Test5    3
Test6    2
Test7

**Sheet2**
Week
2

TASK
Test4
Test6

我一直在尝试做的是:

  • 根据所选的周填充 Sheet2 任务。
  • 如果我选择第 2 周(在 Sheet2 中),它应该使用 Sheet1 中具有该周编号的任务填充任务列表(在同一张工作表上)。

例如,现在(假设)已经加载一周 == 2 的任务。

如有疑问,请告诉我!我希望我说清楚了我的问题。

预先非常感谢您!

I want to populate some cells given certain condition. The thing is, I have no idea how to do this with just formulas (can’t use macros or the sort).

Anyways, here’s my workbook, with its **sheets**:

**Sheet1**
TASK     Week
Test     1
Test2    1
Test3    1
Test4    2
Test5    3
Test6    2
Test7

**Sheet2**
Week
2

TASK
Test4
Test6

What I’ve been trying to do is:

  • Populate Sheet2 tasks based on the week chosen.
  • If I choose week #2 (in Sheet2), it should populate the task list (on the same sheet) with the tasks from Sheet1 that have that week number.

For example, right now it is (hypothetically) already loading tasks with a week == 2.

Any doubt, just let me know! I hope I made my issue clear.

Thank you very much in advance!

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

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

发布评论

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

评论(2

鲸落 2024-12-15 18:10:18

好吧,我找到了更好的解决方案。这需要 Sheet2 上有一个额外的辅助列,但它至少返回一个紧凑的匹配列表(没有奇怪的间距)。

在 Sheet2 上,在匹配列表的第一行(本例中为 A3)中输入以下内容:

=IFERROR(INDEX(Sheet1!$A$1:$A$7,B3),"")

在下一列(此处为 B3)的相邻单元格中输入以下内容:

=IFERROR(MATCH(2,Sheet1!$B$1:$B$7,0),"")

其中 2 是您要匹配的周数。

在下一行中输入以下公式(分别在 A4 和 B4 中):

=IFERROR(INDEX(OFFSET(Sheet1!$A$1:$A$7,SUM(B$3:B3),0),B4),"")

并且

=IFERROR(MATCH(2,OFFSET(Sheet1!$B$1:$B$7,SUM(B$3:B3),0),0),"")

您可以根据需要填写此行公式。

Okay, I found a better solution. This one requires an extra helper column on Sheet2, but it at least returns a compact list of matches (no weird spacing).

On Sheet2, in the first row of your list of matches (A3 in this example) enter the following:

=IFERROR(INDEX(Sheet1!$A$1:$A$7,B3),"")

In the adjacent cell in the next column (B3 here) enter the following:

=IFERROR(MATCH(2,Sheet1!$B$1:$B$7,0),"")

where 2 is the week # you are matching.

In the next row enter the following formulas (in A4 and B4 respectively):

=IFERROR(INDEX(OFFSET(Sheet1!$A$1:$A$7,SUM(B$3:B3),0),B4),"")

and

=IFERROR(MATCH(2,OFFSET(Sheet1!$B$1:$B$7,SUM(B$3:B3),0),0),"")

You can fill down this row of formulas as far as you like.

仙女 2024-12-15 18:10:18

这是我想到的第一种方法。可能有更好、更优雅的解决方案,但我想我会分享。

如果您知道 Sheet1 列表中的任务总数,例如 n,您可以执行以下操作:

  1. 在 Sheet 2 上您想要匹配任务列表的位置,从 A4(或任何您想要的内容)中选择列表顶部)向下至 A(4+n-1)。因此,对于示例数据,请选择 A4:A10
  2. 在不更改选择的情况下,键入以下公式:

    =IF(Sheet1!B2:B8=2,Sheet1!A2:A8,"")

    其中 2 是您要匹配的第 # 周。

  3. 按 Ctrl+Shift+Enter 输入公式。

Here's the first way to do this I thought of. There are probably better, more elegant solutions, but I thought I'd share.

If you know the total number of tasks in your list on Sheet1, say n, you can do the following:

  1. On Sheet 2 where you want your list of matching tasks, select from A4 (or whatever you want the top of your list to be) down to A(4+n-1). So for your sample data, select A4:A10
  2. Without changing the selection, type the following formula:

    =IF(Sheet1!B2:B8=2,Sheet1!A2:A8,"")

    where 2 is the week # you want to match.

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