title: How to sum negative, positive and both based on given month in vba
body: <p>I would like to create my own budget table with vba, but I have an issue.</p>
  
  <p>I would like to sum my expenses, incomes and would like to see a balance. </p>
  
  <p>It is working from a data sheet where both positive and negative amounts are listed in separated columns like bank account or cash. Creating the balance number is going well, but when I would like to see my incomes, so only the sum of the positive numbers by the given date it doesn't work.</p>
  
  <p>It is counts each line where the amount is greater then 0 and ignore the month statement. </p>
  
  <p>Could you please advise how can I solve this issue and see the given months expense?</p>
  
  <pre><code>dim ws2 as worksheet
  set ws2 = worksheets("Data")
  
  dim bk as double
  dim ca as double
  
  mon = MonthName(Month(Date))
  
  For i = 2 To lastrow
  
    bk = ws2.Cells(i, 3)
    ca = ws2.Cells(i, 4)
  
    If mon = MonthName(Month(ws2.Cells(i, 1))) And bk &lt; 0 Or ca &lt; 0  Then
      Expenses = bk + ca + Expenses
    End If
  
  Next i
  </code></pre>