title: Count row with data and specific value from excel in VB.net
body: <p>I have 2  Labels (<strong>lblTotal</strong>) and (<strong>lblYes</strong>) which I put on my form. I want to read an excel file and count how many people come and how many say "yes", like this (<a href="https://imgur.com/a/llfgt6h" rel="nofollow noreferrer">picture</a>). So "lblTotal" will count all row with data (exclude table header) and "lblYes" will show the counting of Answer with "Yes" which updates in <strong>real time</strong>. So far I got the <strong>lblTotal</strong> to work:</p>
  
  <pre><code>Dim xlApp As Excel.Application = Nothing
  Dim xlWorkBooks As Excel.Workbooks = Nothing
  Dim xlWorkBook As Excel.Workbook = Nothing
  Dim xlWorkSheet As Excel.Worksheet = Nothing
  Dim xlWorkSheets As Excel.Sheets = Nothing
  Dim xlCells As Excel.Range = Nothing
  
  Public Sub Total()
          xlApp = New Excel.Application
          xlApp.DisplayAlerts = False
          xlWorkBooks = xlApp.Workbooks
          xlWorkBook = xlWorkBooks.Open("D:\Question\Data.xlsx")
          xlApp.Visible = False
          xlWorkSheet = xlWorkBook.Worksheets("Sheet1")
  
  Dim xx As Integer = xlWorkSheet.UsedRange.Rows.Count - 1
          lblTotal.Text = xx.ToString()
          xlApp.Quit()
  End Sub
  </code></pre>
  
  <p>However, I have no idea how to count row that has the <strong>Yes</strong> answer. Also this doesn't allow real time update. Even though I use a timer to do the job (update on each tick) but it takes it too much to load. For example, in the code above, I used Button to refresh by calling the Total() function in the button click event. </p>
  
  <p>I was thinking about the Button Save event that triggered this update as well. But my biggest question is how can I make it count "Yes" answer only?</p>