Medication 15 days per column in Excel

huangapple go评论69阅读模式
英文:

Medication 15 days per column in Excel

问题

Days January February March April May June July August September October November December
1 PX编号
2 PX名称
3 起始日期 2023年01月21日
4 2
5 3
6
7
8
9
10
11
12
13
14
15
16
17
18 3
19
20 4
21 1
22
23
24
25
26
27
28
29
30
31
英文:
Days January February March April May June July August September October November December
1 PX Number
2 PX Name
3 Start Date 01/21/2023
4 2
5 3
6
7
8
9
10
11
12
13
14
15
16
17
18 3
19
20 4
21 1
22
23
24
25
26
27
28
29
30
31

I'm asking on how can i add 15 days interval depending on start date in this case its 01/21/2023 and it will skip on the other column for another 15 and so on.

This image is on a seperate sheet in excel im just gonna use vlookup to get the value per cell in a another sheet to display it or use pivot table.

答案1

得分: 1

不需要使用VBA,可以使用公式来完成。

假设有以下工作表,其中B1是起始日期,B2是间隔(请注意,您示例中的间隔是14而不是15):

Medication 15 days per column in Excel

然后,您可以在B5:M35中使用以下公式:

=IF(INT((DATE(YEAR($B$1),B$4,$A5)-$B$1)/$B$2+1)=(DATE(YEAR($B$1),B$4,$A5)-$B$1)/$B$2+1,(DATE(YEAR($B$1),B$4,$A5)-$B$1)/$B$2+1,"")

以获得所需的结果。

请注意,月份也需要是数字。

英文:

You don't need VBA for this, it can be done with formulas.

Imagine the following worksheet, where B1 is the start date and B2 the interval (note your interval in your example is 14 not 15):

Medication 15 days per column in Excel

You can then use the following formula in B5:M35

=IF(INT((DATE(YEAR($B$1),B$4,$A5)-$B$1)/$B$2+1)=(DATE(YEAR($B$1),B$4,$A5)-$B$1)/$B$2+1,(DATE(YEAR($B$1),B$4,$A5)-$B$1)/$B$2+1,"")

to get the desired result.

Note that the months need to be numbers too.

huangapple
  • 本文由 发表于 2023年6月1日 10:36:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76378345.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定