求高手解释一下下列VBA语句的意思。
Subfj()Application.ScreenUpdating=FalseSheets(3).Range("2:"&Sheets(3).[a1].CurrentReg...
Sub fj()
Application.ScreenUpdating = False
Sheets(3).Range("2:" & Sheets(3).[a1].CurrentRegion.Rows.Count).ClearContents
For i = 2 To Sheets(1).Range("a65536").End(xlUp).Row
For j = 2 To Sheets(2).Range("a65536").End(xlUp).Row
n = Sheets(3).[a1].CurrentRegion.Rows.Count + 1
If Sheets(1).Cells(i, 5) <> 0 And Sheets(1).Cells(i, 4) = Sheets(2).Cells(j, 1) And Sheets(2).Cells(j, 2) <> "装配" Then
Sheets(3).Cells(n, 1) = Sheets(1).Cells(i, 1)
Sheets(3).Cells(n, 2) = Sheets(1).Cells(i, 4)
Sheets(3).Cells(n, 3) = Sheets(1).Cells(i, 5)
Sheets(3).Cells(n, 4) = Sheets(2).Cells(j, 2)
Sheets(3).Cells(n, 5) = Sheets(2).Cells(j, 3)
Sheets(3).Cells(n, 6) = Sheets(2).Cells(j, 4)
Sheets(3).Cells(n, 7) = Sheets(2).Cells(j, 5)
Sheets(3).Cells(n, 8) = Sheets(3).Cells(n, 3) * Sheets(3).Cells(n, 6)
Sheets(3).Cells(n, 9) = Sheets(3).Cells(n, 3) * Sheets(3).Cells(n, 6) * Sheets(3).Cells(n, 7)
Sheets(3).Cells(n, 10) = Sheets(1).Cells(i, 2)
Sheets(3).Cells(n, 11) = Sheets(1).Cells(i, 3)
n = n + 1
End If
Next
Next
Application.ScreenUpdating = True
End Sub 展开
Application.ScreenUpdating = False
Sheets(3).Range("2:" & Sheets(3).[a1].CurrentRegion.Rows.Count).ClearContents
For i = 2 To Sheets(1).Range("a65536").End(xlUp).Row
For j = 2 To Sheets(2).Range("a65536").End(xlUp).Row
n = Sheets(3).[a1].CurrentRegion.Rows.Count + 1
If Sheets(1).Cells(i, 5) <> 0 And Sheets(1).Cells(i, 4) = Sheets(2).Cells(j, 1) And Sheets(2).Cells(j, 2) <> "装配" Then
Sheets(3).Cells(n, 1) = Sheets(1).Cells(i, 1)
Sheets(3).Cells(n, 2) = Sheets(1).Cells(i, 4)
Sheets(3).Cells(n, 3) = Sheets(1).Cells(i, 5)
Sheets(3).Cells(n, 4) = Sheets(2).Cells(j, 2)
Sheets(3).Cells(n, 5) = Sheets(2).Cells(j, 3)
Sheets(3).Cells(n, 6) = Sheets(2).Cells(j, 4)
Sheets(3).Cells(n, 7) = Sheets(2).Cells(j, 5)
Sheets(3).Cells(n, 8) = Sheets(3).Cells(n, 3) * Sheets(3).Cells(n, 6)
Sheets(3).Cells(n, 9) = Sheets(3).Cells(n, 3) * Sheets(3).Cells(n, 6) * Sheets(3).Cells(n, 7)
Sheets(3).Cells(n, 10) = Sheets(1).Cells(i, 2)
Sheets(3).Cells(n, 11) = Sheets(1).Cells(i, 3)
n = n + 1
End If
Next
Next
Application.ScreenUpdating = True
End Sub 展开
展开全部
Sub fj()
Application.ScreenUpdating = False '关闭屏幕刷新
Sheets(3).Range("2:" & Sheets(3).[a1].CurrentRegion.Rows.Count).ClearContents
'清除第3个工作表当前区域的第2行至末尾行内容
For i = 2 To Sheets(1).Range("a65536").End(xlUp).Row
'变量i从2循环至第1个工作表的末尾行数
For j = 2 To Sheets(2).Range("a65536").End(xlUp).Row
'变量j从2循环至第2个工作表的末尾行数
n = Sheets(3).[a1].CurrentRegion.Rows.Count + 1
'令变量n等于第3个工作表当前区域最大行数+1
If Sheets(1).Cells(i, 5) <> 0 And Sheets(1).Cells(i, 4) = Sheets(2).Cells(j, 1) And Sheets(2).Cells(j, 2) <> "装配" Then
'如果第1个工作表的i行5列的值不等于0,且第1个工作表的i行4列的值等于第2个工作表的j行1列的值,且第2个工作表的j行2列的值不等于装配
Sheets(3).Cells(n, 1) = Sheets(1).Cells(i, 1)
'第3个工作表的n行1列的值等于第1个工作表的i行1列的值
Sheets(3).Cells(n, 2) = Sheets(1).Cells(i, 4)
'第3个工作表的n行2列的值等于第1个工作表的i行4列的值
Sheets(3).Cells(n, 3) = Sheets(1).Cells(i, 5)
'第3个工作表的n行3列的值等于第1个工作表的i行5列的值
Sheets(3).Cells(n, 4) = Sheets(2).Cells(j, 2)
'第3个工作表的n行4列的值等于第2个工作表的j行2列的值
Sheets(3).Cells(n, 5) = Sheets(2).Cells(j, 3)
'第3个工作表的n行5列的值等于第2个工作表的j行3列的值
Sheets(3).Cells(n, 6) = Sheets(2).Cells(j, 4)
'第3个工作表的n行6列的值等于第2个工作表的j行4列的值
Sheets(3).Cells(n, 7) = Sheets(2).Cells(j, 5)
'第3个工作表的n行7列的值等于第2个工作表的j行5列的值
Sheets(3).Cells(n, 8) = Sheets(3).Cells(n, 3) * Sheets(3).Cells(n, 6)
'第3个工作表的n行8列的值等于第3个工作表的n行3列的值乘以第3个工作表的n行6列的值
Sheets(3).Cells(n, 9) = Sheets(3).Cells(n, 3) * Sheets(3).Cells(n, 6) * Sheets(3).Cells(n, 7)
'第3个工作表的n行9列的值等于第3个工作表的n行3列的值乘以第3个工作表的n行6列的值乘以第3个工作表的n行7列的值
Sheets(3).Cells(n, 10) = Sheets(1).Cells(i, 2)
'第3个工作表的n行10列的值等于第1个工作表的i行2列的值
Sheets(3).Cells(n, 11) = Sheets(1).Cells(i, 3)
'第3个工作表的n行11列的值等于第1个工作表的i行3列的值
n = n + 1 '变量j每循环一次,表3行数变量n的值增加1
End If
Next
Next
Application.ScreenUpdating = True '恢复屏幕刷新
End Sub
展开全部
Sub fj()
Application.ScreenUpdating = False
Sheets(3).Range("2:" & Sheets(3).[a1].CurrentRegion.Rows.Count).ClearContents '清空单元格内容
For i = 2 To Sheets(1).Range("a65536").End(xlUp).Row '取表1行数
For j = 2 To Sheets(2).Range("a65536").End(xlUp).Row '取表2行数
n = Sheets(3).[a1].CurrentRegion.Rows.Count + 1 '取表3第一空行行数
If Sheets(1).Cells(i, 5) <> 0 And Sheets(1).Cells(i, 4) = Sheets(2).Cells(j, 1) And Sheets(2).Cells(j, 2) <> "装配" Then '如果表1第5列最后一行非空并且表1的第4列等于表二的第一列并且表2第二列不等于“装配”,那么
Sheets(3).Cells(n, 1) = Sheets(1).Cells(i, 1) '后面都是赋值
Sheets(3).Cells(n, 2) = Sheets(1).Cells(i, 4)
Sheets(3).Cells(n, 3) = Sheets(1).Cells(i, 5)
Sheets(3).Cells(n, 4) = Sheets(2).Cells(j, 2)
Sheets(3).Cells(n, 5) = Sheets(2).Cells(j, 3)
Sheets(3).Cells(n, 6) = Sheets(2).Cells(j, 4)
Sheets(3).Cells(n, 7) = Sheets(2).Cells(j, 5)
Sheets(3).Cells(n, 8) = Sheets(3).Cells(n, 3) * Sheets(3).Cells(n, 6)
Sheets(3).Cells(n, 9) = Sheets(3).Cells(n, 3) * Sheets(3).Cells(n, 6) * Sheets(3).Cells(n, 7)
Sheets(3).Cells(n, 10) = Sheets(1).Cells(i, 2)
Sheets(3).Cells(n, 11) = Sheets(1).Cells(i, 3)
n = n + 1
End If
Next
Next
Application.ScreenUpdating = True
End Sub
Application.ScreenUpdating = False
Sheets(3).Range("2:" & Sheets(3).[a1].CurrentRegion.Rows.Count).ClearContents '清空单元格内容
For i = 2 To Sheets(1).Range("a65536").End(xlUp).Row '取表1行数
For j = 2 To Sheets(2).Range("a65536").End(xlUp).Row '取表2行数
n = Sheets(3).[a1].CurrentRegion.Rows.Count + 1 '取表3第一空行行数
If Sheets(1).Cells(i, 5) <> 0 And Sheets(1).Cells(i, 4) = Sheets(2).Cells(j, 1) And Sheets(2).Cells(j, 2) <> "装配" Then '如果表1第5列最后一行非空并且表1的第4列等于表二的第一列并且表2第二列不等于“装配”,那么
Sheets(3).Cells(n, 1) = Sheets(1).Cells(i, 1) '后面都是赋值
Sheets(3).Cells(n, 2) = Sheets(1).Cells(i, 4)
Sheets(3).Cells(n, 3) = Sheets(1).Cells(i, 5)
Sheets(3).Cells(n, 4) = Sheets(2).Cells(j, 2)
Sheets(3).Cells(n, 5) = Sheets(2).Cells(j, 3)
Sheets(3).Cells(n, 6) = Sheets(2).Cells(j, 4)
Sheets(3).Cells(n, 7) = Sheets(2).Cells(j, 5)
Sheets(3).Cells(n, 8) = Sheets(3).Cells(n, 3) * Sheets(3).Cells(n, 6)
Sheets(3).Cells(n, 9) = Sheets(3).Cells(n, 3) * Sheets(3).Cells(n, 6) * Sheets(3).Cells(n, 7)
Sheets(3).Cells(n, 10) = Sheets(1).Cells(i, 2)
Sheets(3).Cells(n, 11) = Sheets(1).Cells(i, 3)
n = n + 1
End If
Next
Next
Application.ScreenUpdating = True
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询