# Reverse For Each Loop Macro with Wildcard Code

**URL:** <https://forums.unrealengine.com/t/reverse-for-each-loop-macro-with-wildcard-code/308434>\
**Category:** Audio\
**Tags:** reverse, unreal-engine, loop, Blueprint, question\
**Created:** [February 27, 2015, 7:51pm UTC](https://forums.unrealengine.com/t/reverse-for-each-loop-macro-with-wildcard-code/308434 "2015-02-27T19:51:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_8f043ea0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8f043ea0](https://forums.unrealengine.com/u/anonymous_user_8f043ea0)\
**Post date:** [February 27, 2015, 7:51pm UTC](https://forums.unrealengine.com/t/reverse-for-each-loop-macro-with-wildcard-code/308434/1 "2015-02-27T19:51:00Z")

</div>

I wanted an easy way to reverse-iterate through a list of objects such that I could safely remove them by index as I went if needed.

So I created a Blueprint Macro Library and now have it working.

I attach an image of the macro and a usage example in case anyone else would find this useful.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_c0687f281](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_c0687f281](https://forums.unrealengine.com/u/anonymous_user_c0687f281)\
**Post date:** [November 13, 2015, 2:52pm UTC](https://forums.unrealengine.com/t/reverse-for-each-loop-macro-with-wildcard-code/308434/2 "2015-11-13T14:52:39Z")

</div>

Here’s another variant: [[A Little Tip] Remove elements from an array in one pass with a reverse for loop - Programming & Scripting - Epic Developer Community Forums](https://forums.unrealengine.com/showthread.php?69383-A-Little-Tip-Remove-elements-from-an-array-in-one-pass-with-a-reverse-for-loop)

Epic, please integrate! Thank you 🙂

---

<div class="post-metadata">

**Author:** ![Seafra](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Seafra](https://forums.unrealengine.com/u/Seafra)\
**Post date:** [September 30, 2021, 1:37am UTC](https://forums.unrealengine.com/t/reverse-for-each-loop-macro-with-wildcard-code/308434/3 "2021-09-30T01:37:47Z")

</div>

Instead of a For Each loop use a For Loop with first index = 0 and last index = [array length - 1]. Take the output index and connect it to a get node.

 ![349638-custom-for-each-loop.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/7/8/b78b44508b7371ad3ac69d8313befc5b425fc0fc.png)
