title: Function or sub to add new row and data to table
body: <p>I want to create a Sub that basically allows me to target an Excel table with a specific name and then insert a new row at the bottom and add data to that row at the same time. Then exit the sub. And if the table only has one row with no data in it, add the data to that row and then exit the sub. </p>
  
  <p>How can I do this?</p>
  
  <p>I was thinking something like this, in pseudo code:</p>
  
  <pre><code>Public Sub addDataToTable(ByVal strTableName as string, ByVal strData as string, ByVal col as integer)
  
  ActiveSheet.Table(strTableName).Select
  If strTableName.Rows.Count = 1 Then
      strTableName(row, col).Value = strData
  Else
      strTable(lastRow, col).Value = strData
  End if
  
  End Sub
  </code></pre>
  
  <p>This is probably not valid as code at all, but it should explain what I'm after at least!</p>