title: Inserting form values into Excel spreadsheet using VBA
body: <p>I'm trying to insert form values into my Excel spreadsheet using <a href="/questions/tagged/vba" class="post-tag" title="show questions tagged 'vba'" rel="tag">vba</a> but my current code is inserting values into the same row.</p>
  
  <ol>
  <li>As my table starts from <strong>row 3</strong>, I want to start from there and continue by automatically shifting to the next row each time. The rows are already set and I don't want to insert new rows but overwrite the current 'empty' rows.</li>
  <li>When 202 rows (maximum no. of rows available) have been entered then I want the spreadsheet to return an error message dialog.</li>
  </ol>
  
  <p>How can I go about achieving this? </p>
  
  <p><strong>Current Code</strong></p>
  
  <pre><code>    Private Sub btnSubmit_Click()
  
      Dim ws As Worksheet
      Set ws = Worksheets("main")
  
      ' Copy the data to the database
      ws.Rows("4:4").Insert Shift:=xlDown
      ws.Range("A3").Value = cbo_deptCode.Value
      MsgBox ("Booking request has been successfully made")
  
  End Sub
  </code></pre>