I am dealing with VBA for the first time and am having trouble figuring out what is wrong with this method:
Private Sub NewProductButton_Click()
'Find the first empty row in the Products sheet
Dim inputcell As Long, lastcell As Long
inputcell = Products.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
lastcell = Products.Cells(Rows.Count, 1).End(xlUp)
'Submit form data to the sheet
Cells(inputcell, 1) = lastcell + 1
Cells(inputcell, 2) = ProdNameBox
Cells(inputcell, 3) = ProdTypeComboBox
Cells(inputcell, 4) = PrepTimeBox
Cells(inputcell, 5) = CostBox
Cells(inputcells, 6) = PriceBox
'Clear the form
Me.ProdNameBox.Value = ""
Me.ProdTypeComboBox.Value = ""
Me.PrepTimeBox.Value = ""
Me.CostBox.Value = ""
Me.PriceBox.Value = ""
End Sub
This method is supposed to enter the data into the first empty row of the sheet (from a form). The debugger highlights inputcell = Products.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row and throws the error. Any help will be appreciated!
Option Explicitto the top of your module. This will help you locate the source of the error