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