title: Inserting new row of data in excel, every time user click on command button
body: <p>I have started learning VBA programming and thought of creating one small application for inserting student details into an Excel sheet.
  In one Excel sheet named "Main", I have created a form to take user inputs and in another sheet named "Database" I am trying to insert a row of records every time a user clicks the button.</p>
  
  <p>I am successfully able to insert one row of data i.e. first row of data in the database sheet, but my problem is - I want to go to the next row in the sheet once user enters the record and clicks on the button a second time. Similarly for the third time and so on.</p>
  
  <p>My code is:</p>
  
  <pre><code>Private Sub CommandButton1_Click()
  Dim i As String
  Dim j As String
  Dim k As String
  Dim l as integer
  i = Sheets("Main").Cells(1, 2).Value
  j = Sheets("Main").Cells(2, 2).Value
  k = Sheets("Main").Cells(3, 2).Value
  Sheets("Main").Cells(1, 2).Value = ""
  Sheets("Main").Cells(2, 2).Value = ""
  Sheets("Main").Cells(3, 2).Value = ""
  l=2
  Sheets("Database").Cells(l, 1).Value = i
  Sheets("Database").Cells(l, 2).Value = j
  Sheets("Database").Cells(l, 3).Value = k
  End Sub
  </code></pre>
  
  <p>I want to increment value of l by 1, every time user clicks on the command button so that the new record is inserted into the next row of the Database sheet.</p>