title: VBA Excel array writing all values as 0 in cells
body: <p>I have the below code:</p>
  
  <pre><code>Private Sub UpdateButton_Click()    
  
      Dim uniqueID As Integer
      uniqueID = 0
  
      Dim notInOrder As Boolean
      notInOrder = False
  
      Dim inOrder As Boolean
      inOrder = False
  
      Dim employeeNumber As String
  
      Dim week As Integer
  
      Dim tdate As Date
      tdate = Now
  
      Dim qtyWelds As Integer
      qtyWelds = 26
  
  
      Dim totalOfWeldsInOrder As Integer
      totalOfWeldsInOrder = 0
  
  
      Dim qtyGridsInspected As Integer
      qtyGridsInspected = 1
  
      Dim s1 As Integer
      Dim s2 As Integer
      Dim s3 As Integer
      Dim s4 As Integer
      Dim s5 As Integer
      Dim s6 As Integer
      Dim s7 As Integer
      Dim s8 As Integer
      Dim s9 As Integer
      Dim s10 As Integer
      Dim s11 As Integer
      Dim s12 As Integer
      Dim s13 As Integer
      Dim s14 As Integer
      Dim s15 As Integer
      Dim s16 As Integer
      Dim s17 As Integer
      Dim s18 As Integer
      Dim s19 As Integer
      Dim s20 As Integer
      Dim s21 As Integer
      Dim s22 As Integer
      Dim s23 As Integer
      Dim s24 As Integer
      Dim s25 As Integer
      Dim s26 As Integer
  
      If ThisWorkbook.Worksheets(2).Shapes("cBox1").OLEFormat.Object.Value = 0 Then
          totalOfWeldsInOrder = totalOfWeldsInOrder + 1
          s1 = 0
          notInOrder = True
      End If
  
          .....
  
  
      If ThisWorkbook.Worksheets(2).Shapes("cBox26").OLEFormat.Object.Value = 0 Then
          totalOfWeldsInOrder = totalOfWeldsInOrder + 1
          s26 = 0
          notInOrder = True
      End If
  
      Dim sInOrder As Integer
  
      If inOrder = True Then
          sInOrder = 1
      Else
          sInOder = 0
      End If
  
  
      Dim snotInOrder As Integer
  
      If notInOrder = True Then
          snotInOrder = 1
      Else
          snotInOrder = 0
      End If
  
      Dim rowArray(1 To 35) As String
  
  
      uniqueID = GetLastRow() - 1
  
  
      rowArray(1) = uniqueID
  
          .....
  
      rowArray(35) = s26
  
  
      Dim lastRow As Long
  
      lastRow = GetLastRow()
  
      Debug.Print "Last Row: ", lastRow
  
      InsertRow lastRow, rowArray
  
  
  End Sub
  Public Function GetLastRow() As Long
  
      Dim wbshtSelect         As Worksheet
      Dim LR_wbSelectNew      As Long
  
      Set wbshtSelect = Sheets("Data")
  
      ' find last row with data in Column AI9 at current regioun starting at cell AI9
      With wbshtSelect.Range("AI9").CurrentRegion
          LR_wbSelectNew = .Rows(.Rows.Count).Row
      End With
  
      Dim rng         As Range
      Set rng = wbshtSelect.Range("AI9:AI" &amp; LR_wbSelectNew)
  
      ' find last row inside the range, ignore values inside formulas
      LR_wbSelectNew = rng.Find(What:="*", _
                          After:=Range("AI9"), _
                          LookAt:=xlPart, _
                          LookIn:=xlValues, _
                          SearchOrder:=xlByRows, _
                          SearchDirection:=xlPrevious, _
                          MatchCase:=False).Row
  
      GetLastRow = LR_wbSelectNew
  
  End Function
  
  Function InsertRow(lastRow As Long, List() As String)
  
      Dim newRow As Range
      Dim rowArray As Variant
  
      Dim wsData As Worksheet
      Set wsData = Sheets("Data")
  
  
      rowArray = List()
  
      lastRow = lastRow + 1
  
          For Each c In wsData.Range("A" &amp; lastRow &amp; ":AI" &amp; lastRow)
                  For Each s In rowArray
                      c.Value = s
                  Next s
          Next c
  
      Debug.Print "New Row: ", lastRow
  
  End Function
  </code></pre>
  
  <p>I have a button and when I click the Button the macro runs the above code. The code will get the last filled row, and insert data from an array (in code) in the next row. The array is getting populated correctly, however when it comes to writing it to cell all values are returned as 0.</p>
  
  <p>I tried converting the values using <code>CStr(variable)</code> with no success (still saved as 0).</p>
  
  <p>The function that writes values to row:</p>
  
  <pre><code>Function InsertRow(lastRow As Long, List() As String)
  
      Dim newRow As Range
      Dim rowArray As Variant
  
      Dim wsData As Worksheet
      Set wsData = Sheets("Data")
  
  
      rowArray = List()
  
      lastRow = lastRow + 1
  
          For Each c In wsData.Range("A" &amp; lastRow &amp; ":AI" &amp; lastRow)
                  For Each s In rowArray
                      c.Value = s
                  Next s
          Next c
  
      Debug.Print "New Row: ", lastRow
  
  End Function
  </code></pre>
  
  <p>Any idea what I am doing wrong?</p>
  
  <p><strong><em>NOTE1: I am using Office 2007 (Excel)</em></strong></p>
  
  <p><strong><em>NOTE2: I have removed some of the repetitive code.</em></strong> (denoted as .... in code)</p>