title: How to AutoSave as Cell Value with Command Button click in Vba Excel?
body: <p>Looking to add a second function with the click of the command button in Excel with VBA code - first function populates data from worksheet one (an order form) to a database log in worksheet two.  Looking for the second function to be carried out to be an auto-save with cell value from the order form.  Thank you!</p>
  
  <pre><code>Private Sub CommandButton1_Click()
      Dim OrderDate As String, PONumber As String, Vendor As String, ShipTo     As String, SKU As String
      Dim R As Long, LastSKURow As Long, NextDBRow As Long, OFrm As Worksheet, DB As Worksheet
      Set OFrm = Worksheets("Order Form 1")
      Set DB = Worksheets("Database")
      OrderDate = OFrm.Range("B3")
      PONumber = OFrm.Range("D3")
      Vendor = OFrm.Range("B7")
      ShipTo = OFrm.Range("D7")
      LastSKURow = OFrm.Cells(OFrm.Rows.Count, "F").End(xlUp).Row
      For R = 3 To LastSKURow
          SKU = OFrm.Range("F" &amp; R).Value
          NextDBRow = DB.Cells(DB.Rows.Count, "A").End(xlUp).Row + 1
          DB.Range("A" &amp; NextDBRow).Value = OrderDate
          DB.Range("B" &amp; NextDBRow).Value = PONumber
          DB.Range("C" &amp; NextDBRow).Value = Vendor
          DB.Range("D" &amp; NextDBRow).Value = ShipTo
          DB.Range("E" &amp; NextDBRow).Value = SKU
      Next R
      Application.ScreenUpdating = False
      Dim Path As String
      Dim filename As String
          ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF,
          Path = "C:\PDF\"
          filename = OFrm.Range("D3")
          OFrm.SaveAs filename:=Path &amp; filename &amp; ".pdf", FileFormat:=xlPDF
          OpenAfterPublish:=False
      Application.ScreenUpdating = True
  End Sub
  </code></pre>