Excel counting pattern every 5th rows

两盒软妹~` 提交于 2019-12-12 06:03:44

问题


So, I have this 120k rows in excel with format.

id number description
1    1     apple
2    1     banana
3    1     pineapple
4    1     b
5    1     c
6    6     d
7    6     e
8    6     f
9    6     g
10   6     e

what formula can I use in the number column so that it will be the same as the table above? every 5th rows I will change the number of number column based on number on the 6th row of id column. Note that number column is blank right now.


回答1:


Although Enigmativity's solution gives you the desired result, the results will vary by the row from where you start your column. Here is how i would recommend to do it.

Enter 1 in the first cell you want to start the pattern from (B2 in my case) . in the next cell(B3) enter

=IF(MOD(ROW()-ROW($B$2),5)=0,B2+5,B2)

and copy the formula down. This should give you the desired pattern as long as you update the starting cell address (B2 and $B$2)




回答2:


Try this:

 =5*INT((ROW(RC)-1)/5)+1

I get:

1
1
1
1
1
6
6
6
6
6
11
11
11
11
11
16
16

I used R1C1 notation, but just replace the RC with the current cell (i.e. B2) if you're using A1 mode.



来源:https://stackoverflow.com/questions/43750141/excel-counting-pattern-every-5th-rows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!