|
本帖最后由 hfwufanhf2006 于 2020-5-25 19:06 编辑
有点小问题,这与你的合并单元格有关,稍微修改下:
For i = 2 To 11
hs = Sheets(2).[a2].End(4).Row
If Not IsEmpty(Sheets(1).Cells(i, 1)) Then
Sheets(2).Cells(hs + 1, 1) = Sheets(1).Cells(i, 1)
Sheets(2).Cells(hs + 1, 2) = Sheets(1).Cells(i, 2)
Sheets(2).Cells(hs + 1, 3) = Sheets(1).Cells(i, 3)
End If
Next i
当读取到第10个记录时(i=11),最末行就与下一个单元的标题连成了一体,[a2].end(4).row就定位到了下一个单元的标题行了,所以把最末行写入变量比较好,不会因为写入了新的数据而发生改变;
|
|