|
<p>哇,已经这么多人了!</p><p>VBA入门班<font size="6">2组</font>:<font color="#0909f7" size="5">zgwei050</font>交作业:</p><p><font color="#ff3300">Sub 查找唯一()</font><br/>Dim arr1, arr2, arr3()<br/>Dim x As Integer, y As Integer, z As Integer, k As Integer<br/> Range("d2:d65536") = ""<br/> arr1 = Range("A2:A" & Range("A65536").End(xlUp).Row)<br/> arr2 = Range("B2:b" & Range("B65536").End(xlUp).Row)<br/> ReDim arr3(1 To UBound(arr1) + UBound(arr2), 1 To 1)<br/> For x = 1 To UBound(arr1)<br/> arr3(x, 1) = arr1(x, 1)<br/> Next x<br/> For z = 1 To UBound(arr2)<br/> For y = 1 To UBound(arr1)<br/> If arr2(z, 1) = arr1(y, 1) Then GoTo 100<br/> Next y<br/> k = k + 1<br/> arr3(x + k - 1, 1) = arr2(z, 1)<br/>100:<br/> Next z<br/> Range("D2").Resize(x + k, 1) = arr3<br/>End Sub</p><p><br/><font color="#ff3300">Sub 物品1有物品2没有()<br/></font>Dim arr1, arr2, arr3()<br/>Dim x As Integer, y As Integer, z As Integer, k As Integer<br/> Range("E2:E65536") = ""<br/> arr1 = Range("A2:A" & Range("A65536").End(xlUp).Row)<br/> arr2 = Range("B2:b" & Range("B65536").End(xlUp).Row)<br/> ReDim arr3(1 To UBound(arr1), 1 To 1)<br/> <br/> For x = 1 To UBound(arr1)<br/> arr3(x, 1) = arr1(x, 1)<br/> Next x<br/> For z = 1 To UBound(arr1)<br/> For y = 1 To UBound(arr2)<br/> If arr2(y, 1) = arr1(z, 1) Then GoTo 100<br/> Next y<br/> k = k + 1<br/> arr3(k, 1) = arr1(z, 1)<br/>100:<br/> Next z<br/> Range("E2").Resize(k, 1) = arr3<br/>End Sub</p><p><br/><font color="#ff3300">Sub 物品2有物品1没有()</font><br/>Dim arr1, arr2, arr3()<br/>Dim x As Integer, y As Integer, z As Integer, k As Integer<br/> Range("F2:F65536") = ""<br/> arr1 = Range("A2:A" & Range("A65536").End(xlUp).Row)<br/> arr2 = Range("B2:b" & Range("B65536").End(xlUp).Row)<br/> ReDim arr3(1 To UBound(arr1), 1 To 1)<br/> For x = 1 To UBound(arr1)<br/> arr3(x, 1) = arr1(x, 1)<br/> Next x<br/> For z = 1 To UBound(arr2)<br/> For y = 1 To UBound(arr1)<br/> If arr1(y, 1) = arr2(z, 1) Then GoTo 100<br/> Next y<br/> k = k + 1<br/> arr3(k, 1) = arr2(z, 1)<br/>100:<br/> Next z<br/> Range("F2").Resize(k, 1) = arr3<br/>End Sub</p><p><br/><font color="#ff3300">Sub 物品1有物品2也有()</font><br/>Dim arr1, arr2, arr3()<br/>Dim x As Integer, y As Integer, z As Integer, k As Integer<br/> Range("G2:G65536") = ""<br/> arr1 = Range("A2:A" & Range("A65536").End(xlUp).Row)<br/> arr2 = Range("B2:b" & Range("B65536").End(xlUp).Row)<br/> ReDim arr3(1 To UBound(arr1), 1 To 1)<br/> <br/> For x = 1 To UBound(arr1)<br/> arr3(x, 1) = arr1(x, 1)<br/> Next x<br/> For z = 1 To UBound(arr2)<br/> For y = 1 To UBound(arr1)<br/> If arr1(y, 1) <> arr2(z, 1) Then GoTo 100<br/> k = k + 1<br/> arr3(k, 1) = arr2(z, 1)<br/>100:<br/> Next y<br/> Next z<br/> Range("G2").Resize(k, 1) = arr3<br/>End Sub</p><p><br/> </p>
TvHYzLHs.rar
(10.21 KB, 下载次数: 8)
|
|