使用Excel VBA将数据从一个工作表复制到具有合并单元格的其他工作表

时间:2017-03-07 09:15:12

标签: excel-vba vba excel

我使用下面的代码合并单元格,但我不知道如何修改它,如你所建议的那样

Sub mergecells()
Dim lcol as long, lrow as long
With sheets("employee data")
For lrow = 4 to 1000 step 6
For lcol = 1 to 33
.Range(.cells(Row, lcol),.cells(lrow +5, lcol)).merge
Next lcol
For lcol= 42 to 45
.Range(.cells(Row, lcol),.cells(lrow +5, lcol)).merge
Next lcol
For lcol= 49 to 55
.Range(.cells(Row, lcol),.cells(lrow +5, lcol)).merge
Next lcol
Next lrow
End with
End sub

0 个答案:

没有答案