简体   繁体   English

查找数字图案的Excel公式

[英]Find Excel Formula For Number Pattern

I am trying to replicate the following pattern of numbers with an excel formula. 我正在尝试使用excel公式复制以下数字模式。 I am really close, but not quite there, and I could hack it with an if / then statement, but that isn't clean and the formula isn't right. 我确实很接近,但还不很到位,我可以用if / then语句修改它,但这并不干净,公式也不正确。

Here is the pattern of numbers I'm trying to turn into a formula. 这是我要转换为公式的数字模式。

1 2 3 4 5 6 2 3 4 5 6 1 3 4 5 6 1 2 4 5 6 1 2 3 5 6 1 2 3 4 6 1 2 3 4 5 1 2 3 4 5 6 2 3 4 5 6 1 3 4 5 6 1 2 4 5 6 1 2 3 5 6 1 2 3 4 6 1 2 3 4 5

Here is the excel formula that I have that will do this very very closely 这是我拥有的Excel公式,可以非常紧密地执行此操作

=MOD(MOD(ROW()-1,6)+1+FLOOR(((ROW()-1)/6),1),6) = MOD(MOD(ROW() - 1,6)+ 1个+ FLOOR(((ROW() - 1)/ 6),1),6)

This formula spits out the following set of numbers 此公式吐出以下一组数字

1 2 3 4 5 0 2 3 4 5 0 1 3 4 5 0 1 2 4 5 0 1 2 3 5 0 1 2 3 4 0 1 2 3 4 5 1 2 3 4 5 0 2 3 4 5 0 1 3 4 5 0 1 2 4 5 0 1 2 3 5 0 1 2 3 4 0 1 2 3 4 5

Now I know I could do a simple =if(formula=0,6,formula) but that defeats the purpose of trying to get this to expand out with a single formula. 现在我知道我可以做一个简单的= if(formula = 0,6,formula)了,但是这违背了试图用单个公式扩展它的目的。 I'm hoping someone where can help me see what it is I'm missing to make this work. 我希望有人能帮我看看我无法做到这一点。

Thanks! 谢谢!

Andrew 安德鲁

Building on your original formula here's a great big chunk of ugly for you: 在您原始公式的基础上,这为您带来了很大的麻烦:

=MOD(MOD(ROW()-1,6)+1+FLOOR(((ROW()-1)/6),1),6) +
6*FLOOR(ABS(COS(90*MOD(MOD(ROW()-1,6)+1+FLOOR(((ROW()-1)/6),1),6))),1)

Of course if you can use two columns you could compute 当然,如果可以使用两列,则可以计算

column A =MOD(MOD(ROW()-1,6)+1+FLOOR(((ROW()-1)/6),1),6)

Then in column B for each row n:
Bn = An+6*FLOOR(ABS(COS(An)),1)

Don't know about you but I feel kind of dirty after that... 不认识你,但是那之后我有点脏...

What about this one? 这个如何?

=MOD(MOD(MOD(MOD(MOD(MOD(MOD(ROW()-1,6)+1+FLOOR(((ROW()-1)/6),1),6)+1,6),5),4),3),2)*6+MOD(MOD(ROW()-1,6)+1+FLOOR(((ROW()-1)/6),1),6) = MOD(MOD(MOD(MOD(MOD(MOD(MOD(ROW() - 1,6)+ 1个+ FLOOR(((ROW() - 1)/ 6),1),6)+1,6) ,5),4),3),2)* 6 + MOD(MOD(ROW() - 1,6)+ 1个+ FLOOR(((ROW() - 1)/ 6),1),6)

EDIT: the first part is taking care about the troublesome zero. 编辑:第一部分是照顾麻烦的零。 It is your initial formula + 1, but put into 5 different MOD for 2, 3, 4, 5, 6, and then multiplied by 6. So each number different than 0 from your formula will become 0 and 0 will become 1. 它是您的初始公式+ 1,但是将5、2、3、4、5、6的MOD分别乘以6,然后乘以6。因此,与公式不同的每个数字都将变为0,而0将变为1。

I think you want: 我想你要:

=MOD(MOD(ROW()-1,6)+FLOOR(((ROW()-1)/6),1),6)+1

Just move the +1 out of the MOD. 只需将+1移出MOD。

Simpler, for my taste: 就我的口味而言,更简单:

=MOD(ROW()+INT(ROW()/7)-1,6)+1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM