0
내가 처음으로 VBA를 처리하고을 "필요한 개체"및이 방법에 어떤 문제가 있는지 알아내는 데 문제가 있어요 :이 방법은 가정된다VBA 오류
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
입력하기 시트의 첫 x 째 빈 행에 데이터를 입력하십시오 (양식에서). 디버거에서 inputcell = Products.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
을 강조 표시하고 오류가 발생합니다. 어떤 도움을 주시면 감사하겠습니다!
모듈 상단에'Option Explicit '을 추가하십시오. 이렇게하면 오류의 원인을 찾을 수 있습니다. –
@chrisneilsen이 옳습니다. 그가 말하고자하는 것은 변수를 선언하는 것입니다. 적절하게 선언 된 변수를 사용하여 코드를 디버그하는 것이 더 쉽습니다. – L42