|
表单能正常运行,无报错,只是前面21个单元格是可以引用的,而红色那一行的数据,也就是第22列不能从sheet1中引用到sheet2的单元格内,请大侠指教一下是为什么?
Sub 录入数据()
Application.ScreenUpdating = False
Dim i, x, flag
x = 1
Do While Not (IsEmpty(Sheets("sheet2").Cells(x, 1).Value))
x = x + 1
Loop
flag = 0
For i = 1 To x
If Sheets("sheet1").Cells(1, 7) = Sheets("sheet2").Cells(i, 3) Then
flag = 9
Exit For
End If
Next
If flag = 9 Then
x = i
End If
If Sheets("sheet1").Cells(1, 7) = "" Then
MsgBox "代码不能为空"
Else
Sheets("sheet2").Cells(x, 1) = x - 1 '代码
Sheets("sheet2").Cells(x, 2) = Sheets("sheet1").Cells(1, 7) '代码
Sheets("sheet2").Cells(x, 3) = Sheets("sheet1").Cells(1, 10) '图号名称
Sheets("sheet2").Cells(x, 4) = Sheets("sheet1").Cells(2, 8) '计划数量
Sheets("sheet2").Cells(x, 5) = Sheets("sheet1").Cells(2, 11) '结案状态
Sheets("sheet2").Cells(x, 6) = Sheets("sheet1").Cells(3, 3) '生产日期
Sheets("sheet2").Cells(x, 7) = Sheets("sheet1").Cells(3, 5) '材质
Sheets("sheet2").Cells(x, 8) = Sheets("sheet1").Cells(3, 8) '订单数量
Sheets("sheet2").Cells(x, 9) = Sheets("sheet1").Cells(3, 11) '当前数量
Sheets("sheet2").Cells(x, 10) = Sheets("sheet1").Cells(4, 3) '机台
Sheets("sheet2").Cells(x, 11) = Sheets("sheet1").Cells(4, 5) '线径
Sheets("sheet2").Cells(x, 12) = Sheets("sheet1").Cells(4, 8) '热处理温度时间
Sheets("sheet2").Cells(x, 13) = Sheets("sheet1").Cells(4, 11) '喷丸时间
Sheets("sheet2").Cells(x, 14) = Sheets("sheet1").Cells(5, 3) '材料扎数
Sheets("sheet2").Cells(x, 15) = Sheets("sheet1").Cells(5, 5) '旋向
Sheets("sheet2").Cells(x, 16) = Sheets("sheet1").Cells(5, 8) '回火时间温度
Sheets("sheet2").Cells(x, 17) = Sheets("sheet1").Cells(5, 11) '抛光时间
Sheets("sheet2").Cells(x, 18) = Sheets("sheet1").Cells(6, 3) '包装数量
Sheets("sheet2").Cells(x, 19) = Sheets("sheet1").Cells(6, 5) '单重
Sheets("sheet2").Cells(x, 20) = Sheets("sheet1").Cells(6, 8) '淬火硬度
Sheets("sheet2").Cells(x, 21) = Sheets("sheet1").Cells(6, 11) '表面处理
Sheets("sheet2").Cells(x, 22) = Sheets("sheet1").Cells(26, 3) '调机员
MsgBox "录入成功"
End If
End Sub
|
|