基本代码如下:
SubCommandButton1()
\'Sheet1,Sheet2两个表Sheet1复制到Sheet2
\'Sheet1的第一列做判断
DimrowAsInteger,colAsInteger
DimnAsInteger,nRowAsInteger
nRow=1\'复制目标地的起始行
Forrow=1ToSheet1.UsedRange.Rows.Count‘源数据的起始行=1
Forn=1ToCells(row,1)
Forcol=1ToSheet1.UsedRange.Columns.Count
Sheet2.Cells(nRow,col)=Sheet1.Cells(row,col)
Nextcol
nRow=nRow1
Nextn
Nextrow
EndSub
不明白可以要求补充,代码经过测试。 |