注册 登录
编程论坛 Excel/VBA论坛

系统提示定义或应用对象错误,但是我真的找不出错在哪里了。求解答。(刚学10天)

wang3210 发布于 2021-10-09 16:04, 7982 次点击
Public Sub 测试()

Dim i(1 To 11) As String, y As Byte, x As Byte, z As Variant, sz As Variant, m As Byte
i(1) = "*SKU"
i(2) = "*品名"
i(3) = "销售状态"
i(4) = "分类"
i(5) = "品牌"
i(6) = "型号"
i(7) = "开发人"
i(8) = "采购成本(CNY)"
i(9) = "供应商名称"
i(10) = "首选供应商"
i(11) = "供应商采购单价(CNY)"
y = 1
z = Range("a2").CurrentRegion.Rows.Count
Do While y <= 33
For x = 1 To 11 Step 1
If Cells(y).Value Like i(x) Then
 sz = Range(Cells(2, y), Cells(z, y)).Value
 For m = 1 To 33 Step 1
 If Workbooks("product.xlsx").Worksheets(1).Cells(m).Value Like i(x) Then
 Workbooks("product.xlsx").Worksheets(1).Range(Cells(2, y), Cells(z, y)).Value = sz
End If
Next m
End If
Next x
x = 1
y = y + 1
Loop
End Sub
7 回复
#2
wang32102021-10-09 17:29
#3
wang32102021-10-11 09:09



#4
wang32102021-10-11 14:53
咋没人解答。。。在线等。。。
#5
gk03192021-10-29 16:23
cells(y)是什么?
#6
gk03192021-10-29 16:25
cells(y)少一个参数,cells(i,j)这种类型的
#7
秃头少女呀2021-11-30 09:07
cells(y)少参数吧,另外这串代码看的不是特别明白
#8
Anfei19792021-12-11 16:26
if Cells(y).Value Like i(x)
这条语句可以实现两个单元格的数据相等的比较吗???
1