关于Excel宏里编程的问题

来源:百度知道 编辑:UC知道 时间:2024/05/27 11:01:07
先说下问题
有一个表有全部数据和名字
有一个表有全部数据和部分名字
有个空表
要是的在第一个表找相同的数据并补充
然后完整显示在第三个表

在宏里面运行的程序能实现找相同的数据并补充的功能

下面这个程序可以在表中实现这个功能,但是换了个长表就会出现错误,请大虾帮我解决下!谢谢···
Sub 万()
Dim nDes As Long
Dim nSrc As Integer
Dim nRow As Integer
Dim nCount As Integer

Dim strCell1, strCell2 As String
Dim strIndex1, strIndex2 As String
Dim strName1, strName2 As String
Dim r As Range

For nDes = 2 To 2147483647 Step 1
Sheets.Item(2).Select

strIndex2 = "A" + Right(Str(nDes), Len(Str(nDes)) - 1)
Range(strIndex2).Select
strCell2 = ActiveCell.Text

If strCell2 = "" Then
Exit For
End If

Sheets.Item(1).Select

strCell1 = ""

'Cells.Find(What:=strCell2, Look

你可以试下,先用数组存放原单元格的数据,再进行比较分析,然后形成新数组,最后把新数组放到表3就好,你这样复制,粘贴,效率慢。而且容易出问题。
PS:你上面的没有注解,看的不是很懂!