title: Display data in new row using Excel VBA from SQL Server
body: <p>I want to display max(value) of the different oven in a column.</p>
  
  <p>I tried working on it but it is overwriting the next max(value) and feeding it into the same cell instead of displaying it in different rows in the column.</p>
  
  <pre class="lang-vb prettyprint-override"><code>Sub TakeDataFromServer()
  
      Dim conn As ADODB.Connection
      Dim rs As ADODB.Recordset
      Dim fld As ADODB.Field
      Dim mssql As String
      Dim row As Integer
      Dim Col As Integer
      Dim ws As ThisWorkbook
      Dim i As Integer
      Dim rowCount As Integer
      Dim colCount As Integer
  
      Set ws = ThisWorkbook
  
      Application.ScreenUpdating = True
  
      Set conn = New ADODB.Connection
      Set rs = New ADODB.Recordset
  
      startT = Sheet1.Cells(9, 1)
      endT = Sheet1.Cells(9, 5)
  
      For i = 9 To 12    
          oven = Mid(Sheet1.Cells(i, 9), 3, 1)
          Select Case oven
             Case Is = 1
                mssql = "select * from openquery(ihistorian,'set     starttime=08/07/2018,endtime=08/08/2018,intervalmilliseconds=60000,samplingmode=calculated,calculationmode=maximum select max(Value) from ihrawdata where tagname like fix.f1_load* and value &lt;= 750 ')"
  
             Case Is = 2
                mssql = "select * from openquery(ihistorian,'set starttime=08/07/2018,endtime=08/08/2018,intervalmilliseconds=60000,samplingmode=calculated,calculationmode=maximum select max(Value) from ihrawdata where tagname like fix.f2_load* and value &lt;= 750 ')"
  
             Case Is = 3
                mssql = "select * from openquery(ihistorian,'set starttime=08/07/2018,endtime=08/08/2018,intervalmilliseconds=60000,samplingmode=calculated,calculationmode=maximum select max(Value) from ihrawdata where tagname like fix.f3_load* and value &lt;= 750 ')"
  
             Case Is = 4
                mssql = "select * from openquery(ihistorian,'set starttime=08/07/2018,endtime=08/08/2018,intervalmilliseconds=60000,samplingmode=calculated,calculationmode=maximum select max(Value) from ihrawdata where tagname like fix.f4_load* and value &lt;= 750 ')"
  
             Case Is = 5
                mssql = "select * from openquery(ihistorian,'set starttime=08/07/2018,endtime=08/08/2018,intervalmilliseconds=60000,samplingmode=calculated,calculationmode=maximum select max(Value) from ihrawdata where tagname like fix.f5_load* and value &lt;= 750 ')"
  
             Case Is = 6
                mssql = "select * from openquery(ihistorian,'set starttime=08/07/2018,endtime=08/08/2018,intervalmilliseconds=60000,samplingmode=calculated,calculationmode=maximum select max(Value) from ihrawdata where tagname like fix.f6_load* and value &lt;= 750 ')"
  
         End Select
  
         MsgBox oven
  
         conn.ConnectionString = "PROVIDER=MSDASQL;DRIVER={SQL Server};SERVER=10.1.5.7;UID=sa;PWD=V&amp;53zkd"
         conn.ConnectionTimeout = 30
         conn.Open
  
         rs.Open mssql, conn
  
         If rs.EOF Then
            MsgBox "No records found"
            rs.Close
            conn.Close
            Exit Sub
         End If
  
         row = 8
         Col = 29
  
         For rowCount = 1 To 4
            For colCount = 1 To 1
               For Each fld In rs.Fields
                  Sheet1.Cells(row + rowCount, Col + colCount).Value = fld
               Next
            Next colCount 
         Next rowCount 
         rs.Close
         conn.Close
     Next i
  
  End Sub
  </code></pre>
  
  <p>I want my output like this</p>
  
  <pre>
  606
  649
  606
  644
  </pre>
  
  <p>but it is repeating the updated number</p>
  
  <pre>
  644
  644
  644
  644
  </pre>