title: VBA Delete columns in all sheets where sheetname contains text
body: <p>My coding experience is very limited and i'm struggling a bit to understand why my code is not working. I am just going off different forums and help sites to stitch together my code, and i've got parts of it down. The code i've got makes a copy of all Sheets in the workbook, and names it the original name + &quot;_Deal&quot; with this code:</p>
  <pre><code>For Each xWs In ThisWorkbook.Sheets
      xWs.Copy Before:=Sheets(1)
      ActiveSheet.Name = xWs.Name &amp; &quot;_Deal&quot;
  Next
  </code></pre>
  <p>Then i've tried to add this code to delete column 7 (G) from all of the sheets containing &quot;_Deal&quot;:</p>
  <pre><code>For Each xWs In ThisWorkbook.Sheets
  If InStr(ActiveSheet.Name, &quot;_Deal&quot;) &lt;&gt; 0 Then Columns(7).EntireColumn.Delete
  Next
  </code></pre>
  <p>Also tried replacing &quot;ActiveSheet.Name&quot; with &quot;xWs.Name&quot;. The result seems to be that it does delete column 7 in <strong>one</strong> sheet containing &quot;_Deal&quot;, but not all. And i kinda don't understand why the &quot;For Each xWs in ThisWorkbook.Sheets&quot; does work on the first code to actually copy all sheets, while in the second it stops after having executed the code in one sheet..</p>
  <p>I'm going a bit step by step, but my end goal is to 1) Make a copy of all sheets named &quot;... _Deal&quot;, 2) Delete columns 7-10 (G-J) in the copies (but i figured i should just start with one, then figure out how to delete all four columns later), 3) Save all sheets to a new workbook (got that code down), and finally 4) delete the copy sheets containing &quot;_Deal&quot; (not yet attempted that part, but hoping i can use the same as for columns but just switch the delete columns-part with a delete sheet command).</p>
  <p>Any help or input will be appreciated :)</p>