且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

excel如果条件或VBA

更新时间:2022-11-14 11:20:56

假设当A列包含您的A值,C包含您的C值和B包含时的电子表格公式(从第二行开始),则第二行的公式可以写为:

Assuming a spread sheet when column A holds your A values, C holds your C values and B holds the formula (starting at row two), then the formula for row 2 can be written as;

=IF(C2<5,2012-A2+1-(C2-1),IF(A2=2008,1,IF(A2=2009,2,3)))



然后复制到其他行也应填充这些行.

希望这会有所帮助,
Fredrik



Then copied to the other rows should fill those as well.

Hope this helps,
Fredrik


Fredrik Bornander 给出的解决方案1很好.
我要补充一点,从A,C列的值模式观察,连续的三行中每个部分下的A+C总数为2013, 2012, 2011,除了第2部分中的第3行和第2部分中的第2行之外5.我认为通过遵循该模式,这些行中可能会出现键入错误. 如果是这种情况,则正确的值可以是第A部分第2部分第3行中的2009年和第5部分第2行中的2007年中的,还可以使用以下表达式 .
The Solution 1 given by Fredrik Bornander is very good.
I want to add that, as observed from the pattern of values in columns A, C, the total of A+C is 2013, 2012, 2011 under each part in the consecutive three rows, except for row 3 in Part 2 and row 2 in Part 5. I think by following the pattern there may be a typing error in these rows. If that is the case then the correct values could be 2009 in row3 of Part 2 and 2007 in row 2 of Part 5 in Column A and the following expression can also be used.
=IF( AND(A2 <= 2012, A2 >= 2006, C2 >= 1, C2 <= 5),1-(A2+C2-2013),0)