Excel变量X值 [英] Excel variables X values

查看:194
本文介绍了Excel变量X值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个工作日日期,first_date,second_date。



我有一个工作日期递减的数据表:

第二个日期值1 b

第二个日期-1值2

第二个日期-2值3


.... ....



第一个值n



firstdate -1 value n + 1

... ...



(数据表不会在第一天停止)。



我想绘制第一个和第二个日期之间的所有值,仅限工作日。



我发现了一些使用宏的方法,但我希望它可以自动化。



很容易计算行数= NETWORKDAYS(firstdate,seconddate),但我无法设法将这个函数输入到X / Y系列值中。



我有类似='sheet1!$ D $ 4:$ D $ 33。

我需要类似='Sheet1'!$ D $ 4:$ D $& NETWORKDAYS(firstdate,seconddate)



有人知道如何输入它吗?



我努力把NETWORKDAYS (firstdate,seconddate),并在公式中使用cell.value。它是如何工作的?

解决方案

您可以使用 OFFSET 定义一个动态的命名范围。这个名称可以在系列公式中使用。



在我的示例中,单元格D1& A中包含start_date和end_date。 E1分别(如果不是,请根据需要修改公式)。



第1步打开名称管理器,添加一个新名称,如Workdays_Data并在Refers To:框中输入公式:
$ b $ p =(OFFSET(Sheet1!$ D $ 4,0,1,NETWORKDAYS(Sheet1 !$ D $ 1,Sheet1!$ E $ 1),1))





然后关闭Name Manager对话框。



第2步选择数据系列,然后在公式栏中,将引用Values的范围替换为新名称 Workdays_Data 。您需要修改的部分突出显示:



完成更改后,公式栏应如下所示:



如果您这样做,那么每当您更改结束日期时,图表应该会更新。



通过对名称定义进行一些额外的调整,您可以修改这个也是一个动态的开始日期。例如,您可以使用Match函数替换名称公式中的0,以便名称公式为:

=(OFFSET (Sheet8 $ d $ 4 MATCH(Sheet8 $ d $ 1,Sheet8 $ d $ 4:!!!!!$ d $ 11 FALSE)-1,1,NETWORKDAYS(Sheet8 $ d $ 1,Sheet8 $ E $ 1),1))



然后,您可以创建名为 Weekdays_XValues 的另一个名称,并将其用于类别标签在图表中,以便更新以及:

=(OFFSET(Sheet8!$ D $ 4,MATCH(Sheet8!$ D $ 1, Sheet8!$ D $ 4:$ D $ 11,FALSE)-1,0,NETWORKDAYS(Sheet8!$ D $ 1,Sheet8!$ E $ 1),1))



最终结果应该是基于所选开始/结束日期的完全动态图表,如:


I have two working days dates, first_date, second_date.

I have a data table with decreasing working date:

second date value 1

second date - 1 value 2

second date - 2 value 3

.... ....

firstdate value n

firstdate -1 value n + 1

... ...

(Data table doesn't stop at first date).

I want to plot all values between first and second date, only for working days.

I've found some ways with a macro, but I want it to be automated.

It's easy to calculate the number of line with =NETWORKDAYS(firstdate,seconddate), but I can't manage to type this function into the series X/Y values.

I have something like ='sheet1!$D$4:$D$33.

I want something like ='Sheet1'!$D$4:$D$ & NETWORKDAYS(firstdate,seconddate)

Someone know how to type that ?

I've tought about putting NETWORKDAYS(firstdate,seconddate) in a cell and use the cell.value in the formula. How does it works ?

解决方案

You can use the OFFSET function to define a dynamic Named Range. This Name can then be used in the series formula.

In my example I have the start_date and end_date in cells D1 & E1 respectively (if not, modify the formula as necessary).

Step 1 Open the Name Manager, add a new name like "Workdays_Data" and in the Refers To: box, put the formula:

=(OFFSET(Sheet1!$D$4,0,1,NETWORKDAYS(Sheet1!$D$1,Sheet1!$E$1),1))

Then close the Name Manager dialog.

Step 2 Select the data series, and in the formula bar, replace the range that refers to the Values with the new Name, Workdays_Data. The part you need to modify is highlighted:

After you make the change, the formula bar should look like:

If you do this, then the chart should update any time you change the end date.

With some additional tweaking to the Name definition, you could modify this to also account for a dynamic start date. For example, you could replace the "0" in the Name formula with a Match function, so that the name formula reads:

=(OFFSET(Sheet8!$D$4,MATCH(Sheet8!$D$1,Sheet8!$D$4:$D$11,FALSE)-1,1,NETWORKDAYS(Sheet8!$D$1,Sheet8!$E$1),1))

You could then create another Name called Weekdays_XValues and use it for the category labels in the chart, so that those update as well:

=(OFFSET(Sheet8!$D$4,MATCH(Sheet8!$D$1,Sheet8!$D$4:$D$11,FALSE)-1,0,NETWORKDAYS(Sheet8!$D$1,Sheet8!$E$1),1))

The end result should be a fully dynamic chart based on the chosen start/end dates, like:

这篇关于Excel变量X值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆