因兄弟工作需要大批量处理Excel的一些表单,刚研究了一下VBA
帮助他人,快乐自己
直接贴代码
Sub mergeContract()
Dim myCell1 As Range
Dim myCell2 As Range
For Each myCell1 In Sheet1.Range("A2:A8")
For Each myCell2 In Sheet2.Range("A5:A6")
If myCell1.Value = myCell2.Value Then
Sheet2.Cells(myCell2.Row, 2).Copy (Sheet1.Cells(myCell1.Row, 5))
Sheet2.Cells(myCell2.Row, 3).Copy (Sheet1.Cells(myCell1.Row, 6))
End If
Next myCell2
Next myCell1
End Sub
看完代码是不是感觉很傻XXXX