哪位大侠可以帮我写一个EXCEL的宏?

来源:百度知道 编辑:UC知道 时间:2024/05/17 01:28:38
在工作中遇到这样一个EXCEL的应用问题,需要在使用两张表sheet1和sheet2,其中sheet1的A列字符串包含sheet2的A列和B列(就是因为不等于,等于的话我直接用VLOOKUP函数就行了),现在我想对sheet2表中A,B列中所有的单元格,找到在sheet1表中对应A列所在的位置,反馈在C列和D列。哪位大侠用惯宏的帮忙写一下,先谢谢了。

说的比较模糊,你这种情况有函数就可以实现,发给我帮你看看
gulengxian@163.com
发过来时请写明你的要求及这个问题的网址即
(http://zhidao.baidu.com/question/39889707.html?si=4)

sheet1为第一张表,在sheet2表中运行宏abc,宏程序:
Sub abc()
i = 1
Do
i = i + 1
j = 1
Do
j = j + 1
If Cells(i, "A") = Sheets(1).Cells(j, "A") And Cells(i, "A") <> "" Then
Cells(i, "C") = "A" & j
Exit Do
End If
Loop While Sheets(1).Cells(j, "A") <> ""
j = 1
Do
j = j + 1
If Cells(i, "B") = Sheets(1).Cells(j, "A") And Cells(i, "B") <> "" Then
Cells(i, "D") = "A" & j
Exit Do
End If
Loop While Sheets(1).Cells(j, "A") <> ""
Loop While Cells(i, "A") <> "&quo