Office中国论坛/Access中国论坛

标题: 两个EXCEL工作表比较,相同则将一行COPY到另一工作表中!怎么做,谢谢 [打印本页]

作者: junwen1938    时间: 2006-1-25 18:33
标题: 两个EXCEL工作表比较,相同则将一行COPY到另一工作表中!怎么做,谢谢
两个EXCEL工作表比较,相同则将一行COPY到另一工作表中!怎么做,谢谢
作者: pf100    时间: 2006-6-15 22:57
for循环
作者: 飘零红叶    时间: 2006-6-23 01:18
为了加快运行速度,我把两个表拷贝到一张表里了,硬膏能达到你说的功能

Sub duibi()
    Dim e As Integer
    e = InputBox("表1的数据起始行数?")
    Dim w As Integer
    w = InputBox("表1的数据中止行数?")
    Dim x As Integer
    x = InputBox("表2的数据起始行数?")

    Dim y As Integer
    y = InputBox("表2的数据中止行数?")
   
    Dim u As Integer
    u = InputBox("表1中对比数据所在的列数?")
    Dim v As Integer
    v = InputBox("表2中对比数据所在的列数?")
    Dim p As Integer
    p = InputBox("表1中第二个主要数据所在的列数?")
    Dim q As Integer
    q = InputBox("表2中第二个主要数据所在的列数?")
   
    Dim r As Integer
    r = InputBox("如果表2与表1的对比数据相同,则将表2中第一个主要数据拷贝在表1的第几列?")
    Dim s As Integer
    s = InputBox("如果表2与表1的对比数据相同,则将表2中第二个主要数据拷贝在表1的第几列?")

    Dim g As Integer
    g = InputBox("如果表2与表1的对比数据相同,则将表1中第一个主要数据拷贝在表2的第几列?")
    Dim h As Integer
    h = InputBox("如果表2与表1的对比数据相同,则将表1中第二个主要数据拷贝在表2的第几列?")



   Dim i As Integer
   Dim j As Integer

    For i = e To w
    For j = x To y
    If Cells(i, u) = Cells(j, v) Then
       Cells(i, r) = Cells(j, v)
       Cells(i, s) = Cells(j, q)
       End If
       Next j
       Next i
        
    For a = x To y
    For b = e To w
    If Cells(b, u) = Cells(a, v) Then
       Cells(a, g) = Cells(b, u)
       Cells(a, h) = Cells(b, p)
       End If
       Next b
       Next a
End Sub
作者: joyark    时间: 2011-7-3 22:41
不太明白含义,能否举个例子说明一下




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3