From a javascript I'm working on I have
random_img[0]
random_img[1]
random_img[2]
I highlighted these three cells and I tried to use the fill handle to increment the number in the bracket but it doesn't work. Instead of incrementing, the number repeats. For example, I get
random_img[0]
random_img[1]
random_img[2]
random_img[0]
random_img[1]
random_img[2]
I have about 1000 entries (random images) I would like to show.
How can i fix this?
[Solved] Fill feature with numbers in brackets
[Solved] Fill feature with numbers in brackets
Last edited by MrProgrammer on Wed Jan 08, 2025 10:07 pm, edited 1 time in total.
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
OpenOffice 3.4.1 running on Windows 7 - 64bit
- MrProgrammer
- Moderator
- Posts: 5430
- Joined: Fri Jun 04, 2010 7:57 pm
- Location: Wisconsin, USA
Re: Fill function with numbers in brackets
The Autofill feature can increment trailing numbers. However your numbers are in the middle, followed by the ] character. You can use Edit → Find & Replace to remove the ], fill down, then add the ] back. Depending on the content of other cells on the spreadsheet you may need to use More options → Current selection only for these operations. Use a regular expression to add the ] back, activating Find & Replace → More options → Regular expressions and typing .+ in the search field and &] in the replace field.
If you need any additional assistance attach a spreadsheet demonstrating the difficulty (remove confidential information then use Post Reply, not Quick Reply, and don't attach a picture instead of the spreadsheet itself). I will not help further unless you attach a spreadsheet document.
The fill tool is working properly. It just doesn't do what you want.
Another idea: Use Javascript to create the thousand entries with sequential numbers and paste that into Calc.
If this solved your problem please go to your first post use the Edit ✏️ button and add [Solved] to the start of the Subject field. Select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
Re: Fill feature with numbers in brackets
Hi Hansa,
The fill handle doesn’t increment numbers in brackets because it treats the whole string as text. Here's a quick workaround:
Use one column for random_img[ and another for numbers (0, 1, 2...).
Drag the numbers to increment them.
Use =CONCATENATE("random_img[", A1, "]") (or ="random_img[" & A1 & "]") to combine text and numbers.
Drag down to fill your list, then copy-paste as unformatted text.
This will create your sequence correctly. Hope this helps!
The fill handle doesn’t increment numbers in brackets because it treats the whole string as text. Here's a quick workaround:
Use one column for random_img[ and another for numbers (0, 1, 2...).
Drag the numbers to increment them.
Use =CONCATENATE("random_img[", A1, "]") (or ="random_img[" & A1 & "]") to combine text and numbers.
Drag down to fill your list, then copy-paste as unformatted text.
This will create your sequence correctly. Hope this helps!
OpenOffice 4.1.14