title: How do I copy/paste cell values if the condition is true and enter "0" if the cell being looked at in the condition isn't there?
body: <p>I'm very new to VBA and I haven't been able to figure this out yet. </p>
  
  <p>I need a code that copies cell <code>.Range("E" &amp; i)</code> to cell <code>Sheets("CANmonitor").Range("C" &amp; k)</code> if Column <code>B = 1731</code>. </p>
  
  <p>However, it needs to look at <code>.Range("C" &amp; i)</code> as well and set <code>Sheets("CANmonitor").Range("C" &amp; K) = 0</code> if <code>.Range("C" &amp; i)</code> is between <code>6</code> &amp; <code>16</code> or between <code>28</code> &amp; <code>39</code>. </p>
  
  <p>To simplify, the value on column <code>C</code> jumps from <code>6</code> to <code>16</code> and from <code>28</code> to <code>39</code>. I need the code to enter <code>0s</code> for the missing values (ex: <code>1731.6</code> = data from <code>cell ("E" &amp; i)</code> on sheet <code>DIC2</code>; <code>1731.7</code> = <code>0</code>). Here's what I have so far:</p>
  
  <pre><code>Sub DIC2toCAN()
      Dim LR As Long, i As Long, k As Long
  
      With Sheets("DIC2")
          LR = .Range("B" &amp; Rows.Count).End(xlUp).Row
  
          k = 1
          For i = 1 To LR
              With .Range("B" &amp; i)
                  If .Value = "1731" Then
                      If .Range("C" &amp; i) is between 6 &amp; 16 or is between 28 &amp; 39 Then
                          Sheets("CANmonitor").Range("C" &amp; k) = 0
                      Else
                          Sheets("DIC2").Range("E" &amp; i).Copy _
                          Destination:=Sheets("CANmonitor").Range("C" &amp; k)
                          k = k + 1
                      End If
                  End If
              End With
          Next i
      End With
  End Sub
  </code></pre>