The problem is that you're not using the variable specified in the For Each action in your subsequent actions. I take it from the macro you've shown us that you're looking to erase underscores from the beginning and end of selected file names, so here's a macro that I believe should answer your question and hopefully solve your usecase in a simpler way than what you currently have: