简体   繁体   中英

Print number x number of times based on value of a cell

I have one column with a certain ID number an A1, and another number in B1. How can I make a cell with A1 written as many times as the number in B1 (taking for granted the formula can be extrapolated downward.)

You want to make use of the REPT function, like this:

      A      B
      ---    ---
1:    42     5
2:    =REPT(A1, B1)

This will output:

4242424242

In C1

=IF(ROW()<=$B$1,$A$1,"")

and copy down for the largest B1 you expect. It will put whatever is in A1 in C1:C?. It checks the row of the the cell that contains the formula, ROW(), against the number in B1. If you're starting in a row other than row 1, you'll need to adjust. For example, if you're starting in row 6

=IF(ROW()-5<=$B$6,$A$6,"")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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