EXCEL中VB提取多个工作表中的数据 提取的数据某些列上移,其他列正常
我通过中介绍的办法提取数据,但是在h列数据上移了1行,t列上移了4行(如图),请问是怎么回事??Sub数据提取()Fori=2ToWorksheets.CountShee...
我通过中介绍的办法提取数据,但是在h列数据上移了1行,t列上移了4行(如图),请问是怎么回事??
Sub 数据提取()
For i = 2 To Worksheets.Count
Sheets(1).Cells(Sheets(1).[a65536].End(3).Row+ 1, 1) = Sheets(i).[a2]
Sheets(1).Cells(Sheets(1).[b65536].End(3).Row+ 1, 2) = Sheets(i).[a3]
Sheets(1).Cells(Sheets(1).[c65536].End(3).Row+ 1, 3) = Sheets(i).[b19]
Sheets(1).Cells(Sheets(1).[d65536].End(3).Row+ 1, 4) = Sheets(i).[c19]
Sheets(1).Cells(Sheets(1).[e65536].End(3).Row+ 1, 5) = Sheets(i).[d19]
Sheets(1).Cells(Sheets(1).[f65536].End(3).Row+ 1, 6) = Sheets(i).[e19]
Sheets(1).Cells(Sheets(1).[g65536].End(3).Row+ 1, 7) = Sheets(i).[f19]
Sheets(1).Cells(Sheets(1).[h65536].End(3).Row+ 1, 8) = Sheets(i).[g19]
Sheets(1).Cells(Sheets(1).[i65536].End(3).Row+ 1, 9) = Sheets(i).[h19]
Sheets(1).Cells(Sheets(1).[j65536].End(3).Row+ 1, 10) = Sheets(i).[h7]
Sheets(1).Cells(Sheets(1).[k65536].End(3).Row+ 1, 11) = Sheets(i).[i7]
Sheets(1).Cells(Sheets(1).[l65536].End(3).Row+ 1, 12) = Sheets(i).[j7]
Sheets(1).Cells(Sheets(1).[m65536].End(3).Row+ 1, 13) = Sheets(i).[k7]
Sheets(1).Cells(Sheets(1).[n65536].End(3).Row+ 1, 14) = Sheets(i).[l7]
Sheets(1).Cells(Sheets(1).[o65536].End(3).Row+ 1, 15) = Sheets(i).[m7]
Sheets(1).Cells(Sheets(1).[p65536].End(3).Row+ 1, 16) = Sheets(i).[n7]
Sheets(1).Cells(Sheets(1).[q65536].End(3).Row+ 1, 17) = Sheets(i).[o7]
Sheets(1).Cells(Sheets(1).[r65536].End(3).Row+ 1, 18) = Sheets(i).[p7]
Sheets(1).Cells(Sheets(1).[s65536].End(3).Row+ 1, 19) = Sheets(i).[q7]
Sheets(1).Cells(Sheets(1).[t65536].End(3).Row+ 1, 20) = Sheets(i).[r7]
Next
End Sub
http://zhidao.baidu.com/link?url=UzUaljrHu04dZ7C5V0x7VchKdFMo_VhAyvWYjMMD5MxD3g7fKQQRT9LCkb2fStdtRiLNRhr12e1W4hann_fkUNp_kFX4GWqVPFa-dunuMrW 展开
Sub 数据提取()
For i = 2 To Worksheets.Count
Sheets(1).Cells(Sheets(1).[a65536].End(3).Row+ 1, 1) = Sheets(i).[a2]
Sheets(1).Cells(Sheets(1).[b65536].End(3).Row+ 1, 2) = Sheets(i).[a3]
Sheets(1).Cells(Sheets(1).[c65536].End(3).Row+ 1, 3) = Sheets(i).[b19]
Sheets(1).Cells(Sheets(1).[d65536].End(3).Row+ 1, 4) = Sheets(i).[c19]
Sheets(1).Cells(Sheets(1).[e65536].End(3).Row+ 1, 5) = Sheets(i).[d19]
Sheets(1).Cells(Sheets(1).[f65536].End(3).Row+ 1, 6) = Sheets(i).[e19]
Sheets(1).Cells(Sheets(1).[g65536].End(3).Row+ 1, 7) = Sheets(i).[f19]
Sheets(1).Cells(Sheets(1).[h65536].End(3).Row+ 1, 8) = Sheets(i).[g19]
Sheets(1).Cells(Sheets(1).[i65536].End(3).Row+ 1, 9) = Sheets(i).[h19]
Sheets(1).Cells(Sheets(1).[j65536].End(3).Row+ 1, 10) = Sheets(i).[h7]
Sheets(1).Cells(Sheets(1).[k65536].End(3).Row+ 1, 11) = Sheets(i).[i7]
Sheets(1).Cells(Sheets(1).[l65536].End(3).Row+ 1, 12) = Sheets(i).[j7]
Sheets(1).Cells(Sheets(1).[m65536].End(3).Row+ 1, 13) = Sheets(i).[k7]
Sheets(1).Cells(Sheets(1).[n65536].End(3).Row+ 1, 14) = Sheets(i).[l7]
Sheets(1).Cells(Sheets(1).[o65536].End(3).Row+ 1, 15) = Sheets(i).[m7]
Sheets(1).Cells(Sheets(1).[p65536].End(3).Row+ 1, 16) = Sheets(i).[n7]
Sheets(1).Cells(Sheets(1).[q65536].End(3).Row+ 1, 17) = Sheets(i).[o7]
Sheets(1).Cells(Sheets(1).[r65536].End(3).Row+ 1, 18) = Sheets(i).[p7]
Sheets(1).Cells(Sheets(1).[s65536].End(3).Row+ 1, 19) = Sheets(i).[q7]
Sheets(1).Cells(Sheets(1).[t65536].End(3).Row+ 1, 20) = Sheets(i).[r7]
Next
End Sub
http://zhidao.baidu.com/link?url=UzUaljrHu04dZ7C5V0x7VchKdFMo_VhAyvWYjMMD5MxD3g7fKQQRT9LCkb2fStdtRiLNRhr12e1W4hann_fkUNp_kFX4GWqVPFa-dunuMrW 展开
1个回答
展开全部
Sub 数据提取()
For i = 2 To Worksheets.Count
r=Sheets(1).[a65536].End(3).Row+ 1
'上面这行在第一列上取最下一行的号,你原来的每列都取最后一行的下一行,有时你前面的数据有空单元格,就会取到和第一列不一样的行号所以就出现了错行的情况
Sheets(1).Cells(R, 1) = Sheets(i).[a2]
Sheets(1).Cells(R, 2) = Sheets(i).[a3]
Sheets(1).Cells(R, 3) = Sheets(i).[b19]
Sheets(1).Cells(R, 4) = Sheets(i).[c19]
Sheets(1).Cells(R, 5) = Sheets(i).[d19]
Sheets(1).Cells(R, 6) = Sheets(i).[e19]
Sheets(1).Cells(R, 7) = Sheets(i).[f19]
Sheets(1).Cells(R, 8) = Sheets(i).[g19]
Sheets(1).Cells(R, 9) = Sheets(i).[h19]
Sheets(1).Cells(R, 10) = Sheets(i).[h7]
Sheets(1).Cells(R, 11) = Sheets(i).[i7]
Sheets(1).Cells(R, 12) = Sheets(i).[j7]
Sheets(1).Cells(R, 13) = Sheets(i).[k7]
Sheets(1).Cells(R, 14) = Sheets(i).[l7]
Sheets(1).Cells(R, 15) = Sheets(i).[m7]
Sheets(1).Cells(R, 16) = Sheets(i).[n7]
Sheets(1).Cells(R, 17) = Sheets(i).[o7]
Sheets(1).Cells(R, 18) = Sheets(i).[p7]
Sheets(1).Cells(R, 19) = Sheets(i).[q7]
Sheets(1).Cells(R, 20) = Sheets(i).[r7]
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |