title: Countif inside if VBA
body: <p>What I want to do is count how many times the tags have been used in each type and write them into a different sheet. My data are as follow.</p>
  
  <p>        <a href="https://i.stack.imgur.com/j0BqP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j0BqP.png" alt="Sample data"></a></p>
  
  <p>For this example, it would be like this:</p>
  
  <pre><code>         A  B   C   D   F   H   K   L   M   N
  Type1    1  1   1   2   1   1
  Type2    1  1   1           1   1   2   1   1 
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>Sub Countif_trial()
  
  Dim myString As String
  Dim xRange As Range
  
  Set xRange = Range("C2:C8")
  
  myString = Range("A2").Value
  
  If InStr(myString, Type1) Then
  
  Range("h1").Value = Application.CountIf(xRange, "A")
  End If
  
  End Sub
  </code></pre>