0
我正在嘗試在Excel中編寫一個VBA子例程來創建客戶價目表。爲什麼我得到類型不匹配錯誤
當我逐句通過例行程序時,在我放置星號的行處出現類型不匹配。有人可以解釋我做錯了嗎?下面是我寫到目前爲止的代碼,可能還有更多我還沒有發現的錯誤。
Sub Create_Customer_Price_List()
Dim Counter1 As Integer
Dim Counter2 As Integer
Dim SectionNum As Integer
Dim ProdNum As Integer
Dim ProductID As String
Dim ProductSection As String
Worksheets("BH").Activate
SectionNum = Range("J10", Range("J10").End(xlDown)).Rows.Count
Range("J10").Select
For Counter1 = 1 To SectionNum
If ActiveCell.Value <> 0 Then
ProductSection = ActiveCell.Offset(0, 1).Value
* Range("B9").Offset(Range("B9").End(xlDown), 3).Value = ProductSection
End If
ProdNum = Range("J10").Value
For Counter2 = 1 To ProdNum
ProductID = Range("L10").Value & Counter2
Range("B9").Offset(Counter2, 0).Value = ProductID
Next Counter2
Range("J10").Offset(Counter1 + 1, 0).Select
Next Counter1
End Sub
什麼細胞,你想寫'ProductSection'到?使用列中的最後一個單元格作爲行偏移量並沒有多大意義。 – Comintern
你應該避免使用'Activate','Select'和'ActiveCell',而不要使用'With Worksheets(「BH」)'',如果.Cells(「J」&10 + Counter1).Value <> 0 Then' –
感謝您的意見,我理解他們的理由。當我應用這個時,我得到一個無效的過程調用或參數錯誤。對不起,我對VBA很陌生。 – HarvB