Hi @pennytron , Sorry for the delay 
I am not sure what you did wrong with the IF, but next time if you can send the automation it will be easier to find the error.
You were right in your attempt, it require only 1 IF line, as the first line under the loop “layers in the active comp”, it quite simple
Check out this edited automation, the IF line is colored redץ
Download -
Export Comp as CSV Enabled.zip (4.0 KB)
I am glad you found a solution 
I will try to explain a little bit about collections:
Collection is a list of things, it can be Numbers, Texts, Layers, Items, Properties or Boolean.
It can contain only 1 type of these objects, so it can’t contain Texts and Layers.
each object in the collection is referred as “element” in the UI,
we can visualize a collection using this format - [“Text 1”, “Text 2”, “Text 3”]
This collection have 3 elements inside, the first 1 is “text 1” and the last one is “text 3”.
we can create this collection like this -

- In this automation we create an empty collection →
- We added an element to the collection at the last place so the result is → [“Text 1”]
- We added another element to the collection at the last place so the result is → [“Text 1”, “Text 2”]
- At last we added an element to the collection so the result is → [“Text 1”, “Text 2”, “Text 3”]

There are multiple available actions to manipulate the collection -
- You can add element after the last element.
- Add Element at a specific position in the middle of the collection.
- Remove Element is a specific position.
- There are more utility actions that lets you poppulate the collection eailsy.
(each collection type have different actions )
You can also change specific element in the collection by its index.
Check out this automation -
At the last 2 lines we override an element in the collection -
- We created earlier in the 4 first lines this collection → [“Text 1”, “Text 2”, “Text 3”]
- In line 5 we Set the “index” property of the collection to 2
- Then we Set a collection property called “element at index” and we give it a new value of “New Element”, the result → [“Text 1”, “New Element”, “Text 3”]
Last you can loop over the elements in a collection using the loop “elements in collection”.
This loop goes over each element in a collection and sets each time the index of the collection to the current element index, so the “index” property of the collection will be updated automatically by this loop.
The loop also passes a variable with the value of the current element in the collection.
keep in mind that this variable is not linked to the original element inside the collection (its duplicated) and you will have to update the element in the collection to save changes you have made to it (using the set “element at index”).
Example:
You can filter element in a collection by looping over the collection, and check the value of each element, and if the value is needed to be removed you can remove the current element.
- We continue from the last automation that builds a collection → [“Text 1”, “New Element”, “Text 3”]
- In the blue part we first loop over the elements in the collection.
- we check if the current element value is “Text 1” and if it is we will use the collection action “remove element at index” (the index is set automatically by the loop to the current layer)
Long post, I hope it helps to understand collections more, I recommend you try it yourself, like in the example build collections and manipulate them in different ways until you get it.
Please let me know if you have more questions.