How to repeat a string and know the index

Consider this text in a single cell http://localhost/image_1.jpg, http://localhost/image_2.jpg, http://localhost/image_3.jpg I need to generate the text using a formula where I simply type how many images I need, I’ve tried to use the REPT function but I can’t know the current index to append it:

= REPT(CONCATENATE("http://localhost/image"; "_1.jpg, "); 2)

The formula above generates http://localhost/image_1.jpg, http://localhost/image_1.jpg, (the last , is no big deal), is there a function that auto-increment a number in each cell? any alternatives?

Try

=TEXTJOIN(", ";0;"http://localhost/image_" & ROW(INDIRECT("A1:A" & CountImages)) & ".jpg")

where CountImages is cell with number of images

Thanks so much, it works! if it’s possible, can you please explain how this works? I’ve read each function in your solution but I can’t figure out how they fit together.

@araftel:

Enter ="http://localhost/image_" & ROW(INDIRECT("A1:A" & CountImages)) & ".jpg" (or only =ROW(INDIRECT("A1:A" & CountImages))) into a cell and finalize with CTRL+SHIFT+ENTER to turn that to an array formula and see what you get. See also: LibreOffice Help - Array Functions - Function TEXTJOIN() (just like function SUMPRODUCT() does for numerical data) forces array evaluation for text data.

@anon73440385 Thank you! That makes much more sense now, I didn’t know about CTRL+SHIFT+ENTER