关于VB操控XCEL的问题
请教高手!有两张EXCEL表甲乙,其中甲表中有A,B,C两个字段,乙表中有A,B,C字段。甲A和乙A行中的数据相等,甲B和乙B行中的数据相等。问题是当甲A1=乙A1和甲B1=乙B1相等成立时,甲C1单元格值等于乙C1数据。如下:
表甲:
|...A...|...B...|...C...|
|2345134|3456.00|.......|
|4552267|5634.87|4388912|
|2312346|..54.32|.......|
|5322789|8845.32|.......|
......
表乙:
|...A...|...B...|...C...|
|2345134|3456.00|9944487|
|2312346|..54.32|6547333|
|5322789|8845.32|3421455|
VB处理后表:
|...A...|...B...|...C...|
|2345134|3456.00|9944487|
|4552267|5634.87|4388912|
|2312346|..54.32|6547333|
|5322789|8845.32|3421455|
谢谢!
--------------------编程问答--------------------
dim sh1,sh2
dim i%,j%
set sh1=worksheets("甲")
set sh2=worksheets("乙") '若表名不一样或不在一个文件中请自己百度
for i=1 to sh1.UsedRange.Rows.Count '取sh1的最大行数
for j=1 to sh2.UsedRange.Rows.Count '取sh2的最大行数
if sh1.cells(i,1)=sh2.cells(j,1) and sh1.cells(i,2)=sh2.cells(j,2) then
sh1.cells(i,3)=sh2.cells(j,3)
end if
next
next
补充:VB , 控件