daixinet

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

一个朋友让我帮他处理一个Excel,对比两个Sheet中的字段,然后赋值。

我学过VB,但是对Excel的VBA编程还是第一次,然而代码都是一样的。

Sub GetMultNum()
    For i = 8 To 12
        For j = 2 To 171
            If Sheet14.Cells(i, 3) = Sheet2.Cells(j, 3) And Sheet14.Cells(i, 2) = Sheet2.Cells(j, 2) Then
                Sheet14.Cells(i, 6) = Sheet2.Cells(j, 4)
            End If
        Next j
    Next i
End Sub

 

 

 

 

posted on 2012-10-10 20:58  daixinet.com  阅读(194)  评论(0编辑  收藏  举报