|
为了加快运行速度,我把两个表拷贝到一张表里了,硬膏能达到你说的功能
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 |
|