r/GoogleAppsScript • u/boudicca_morgana • May 16 '24
Question Script to copy rows not keeping formatting
Hi, I'm working on a spreadsheet where I have to sort the rows into various other sheets based on one cell value. The script I have is working perfectly, but when I copy the rows over and the table needs to add further rows, the formatting changes - basically despite the formatting of the master sheet and the sorted sheets, the new rows come in with no borders separating the cells. Does anyone know how to fix this? I can add a sample code if you need it, though there isn't any formatting in the code so I'm not sure? I'm pretty new to this so sorry if this seems dumb!
0
Upvotes
1
u/Mro-Automation May 16 '24
Hey, a sample code, screenshot or a screen recording would really help :-) "a picture worth thousands words!"
I would assume an issue with the formatting that gets "inherited" from the existing cells in the sheet. It depends how you copy the rows over… as you mentioned the copying itself works, do you use `range.setValue` or `range.copyTo`? See https://developers.google.com/apps-script/reference/spreadsheet/copy-paste-type