Hi @Smallbadger, if Eugene's link (a great article!) doesn't solve your problem I suspect it might be because of your subhead rows, which could complicate things. I've written a quick script to set each row of a table in alternating cell styles, resetting when encountering subhead rows. If you are happy to play with scripting, you may be able to adapt it to your specific needs.
To use it you will need to (1) add a new cell style called "BODY ALT", based on "BODY" and give it a cell fill colour of 15% cyan (or whatever) *and* set the BODY cell style's fill colour to "[Paper]" (or whatever you want). Once you've done that, select your table and run the script.
Note: The script explicitly applies the "SUBCELL" style to the subhead cells—comment out that line if you don't want this.
/*
by m1b
here: https://community.adobe.com/t5/indesign/need-urgent-help-with-alternating-table-fills/m-p/12190571#M438057
*/
// table cell style names:
var styleName1 = 'BODY',
styleName2 = 'BODY ALT',
subheadStyleName = "SUBCELL";
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Set alternating table styles");
function main() {
if (app.selection.length == 0) {
alert('Please make a selection and run script again.');
} else if (!app.selection[0].parentStory.tables[0].isValid) {
alert('No table found in selection.');
} else {
var _table = app.selection[0].parentStory.tables[0];
var _rows = _table.rows;
var alternator = 0;
for (var i = 0; i < _rows.length; i++) {
if (_rows[i].rowType === RowTypes.BODY_ROW) {
if (_rows[i].cells.length == 1) {
// row is a subhead (all cells are merged into one)
setStyle(
app.activeDocument,
_rows[i].cells[0],
'cellStyle',
subheadStyleName,
true
);
// reset alternator flag
alternator = 0;
} else {
// set body cell style according to alternator flag
setStyle(
app.activeDocument,
_rows[i].cells.everyItem(),
'cellStyle',
alternator == 1 ? styleName2 : styleName1,
true
);
// switch the alternator between 0 and 1
alternator = (alternator + 1) % 2;
}
}
}
}
// just a convenience function for setting styles
function setStyle(doc, item, styleType, styleName, clearOverrides) {
if (doc == undefined || item == undefined || styleName == undefined) return;
if (clearOverrides == undefined) clearOverrides = true;
switch (styleType.toLowerCase()) {
case 'cellstyle':
if (doc.cellStyles.itemByName(styleName).isValid) {
item.appliedCellStyle = doc.cellStyles.itemByName(styleName);
if (clearOverrides) item.clearCellStyleOverrides(false);
} else {
throw ('Cell Style "' + styleName + '" not found.');
}
break;
case 'paragraphstyle':
if (doc.paragraphStyles.itemByName(styleName).isValid) {
item.texts[0].paragraphs.everyItem().appliedParagraphStyle = doc.paragraphStyles.itemByName(styleName);
if (clearOverrides) item.texts[0].clearOverrides(OverrideType.ALL);
} else {
throw ('Paragraph Style "' + styleName + '" not found.');
}
break;
case 'characterstyle':
if (doc.characterStyles.itemByName(styleName).isValid) {
item.texts[0].paragraphs.everyItem().appliedCharacterStyle = doc.characterStyles.itemByName(styleName);
if (clearOverrides) item.texts[0].clearOverrides(OverrideType.CHARACTER_ONLY);
} else {
throw ('Character Style "' + styleName + '" not found.');
}
break;
default:
throw ('Unrecognised styleType "' + styleType + '".');
break;
}
}
}
Let me know if that works for you.
- Mark
Edit: the downside of this script is that it will apply the style to the entire row, so if you have different cell styles for different columns, it won't work, although with a bit of finesse it can be adjusted. One possibility is to change the "clearOverrides" flag on the setStyles function calls to false, but it will depend on how the table is set up whether this works. Or you could adjust the script to set each cell of each row specifically.