title: Using "If cell contains" in VBA excel
body: <p>I'm trying to write a macro where if there is a cell with the word "TOTAL" then it will input a dash in the cell below it. For example:</p>
  
  <p><img src="https://i.stack.imgur.com/pU3Tb.png" alt="enter image description here"></p>
  
  <p>In the case above, I would want a dash in cell F7 (note: there could be any number of columns, so it will always be row 7 but not always column F).</p>
  
  <p>I'm currently using this code, but it's not working and I can't figure out why.</p>
  
  <pre><code>Dim celltxt As String
  Range("C6").Select
  Selection.End(xlToRight).Select
  celltxt = Selection.Text
  If InStr(1, celltext, "TOTAL") &gt; 0 Then
  Range("C7").Select
  Selection.End(xlToRight).Select
  Selection.Value = "-"
  End If
  </code></pre>
  
  <p>Help would be appreciated. Hopefully I'm not doing something stupid.</p>