New to VBA and Excel, haven't programmed anything in years. Quick question. We're trying to make an Inventory list in Excel With a button calling an input Box where data can be inserted. The data from the input boxes should eb inserted into the first available row. There are 10 columns per row, and each row represents a new item in the Inventory. Here is my code, which gives me "Run-time error 424: Object required":
Dim iDate, iVessel, iOrder, iCourier, iWaybill, iSender, iPcs, iWeight, iRemark As Variant
Dim col As Integer
Public Function selectFirstBlankCell()
Dim sourceCol As Integer, rowCount As Integer, currentRow As Integer
Dim currentRowValue As String
col = 2
sourceCol = col
rowCount = Cells(Rows.Count, sourceCol).End(xlUp).Row
While col < 11
For currentRow = 1 To rowCount
currentRowValue = Cells(currentRow, sourceCol).Value
If IsEmpty(currentRowValue) Or currentRowValue = "" Then
Cells(currentRow, sourceCol).Select
If sourceCol = 2 Then
Cell.Value = iDate
ElseIf sourceCol = 3 Then
Cell.Value = iVessel
ElseIf sourceCol = 4 Then
Cell.Value = iOrder
ElseIf sourceCol = 5 Then
Cell.Value = iCourier
ElseIf sourceCol = 6 Then
Cell.Value = iWaybill
ElseIf sourceCol = 7 Then
Cell.Value = iSender
ElseIf sourceCol = 8 Then
Cell.Value = iPcs
ElseIf sourceCol = 9 Then
Cell.Value = iWeight
ElseIf sourceCol = 10 Then
Cell.Value = iRemark
End If
col = col + 1
End If
Next
Wend
End Function
Public Sub newParcel_Click()
Call selectFirstBlankCell
iDate = InputBox("Tast inn dato, format dd.mm.yyy")
iVessel = InputBox("Tast inn båtens navn")
iOrder = InputBox("Tast inn eventuell P.O.")
iCourier = InputBox("Tast inn courier")
iWaybill = InputBox("Tast inn waybillnummer")
iSender = InputBox("Tast inn avsender")
iPcs = InputBox("Tast inn antall kolli")
iWeight = InputBox("Tast inn vekt")
iRemark = InputBox("Tast inn eventuelle anmerkninger")
End Sub