|
合并单元格
如图,表中第三和第四行相同内容需合并单元格,以下代码出错,请问大神们.merge这句哪里错了?该如何修改?谢谢
Sub hbrglx()
Application.DisplayAlerts = False
Dim i As Integer
For i = 2 To 7
If Cells(4, i) = Cells(5, i) Then
Range("cells(4,i):cells(5,i)").Merge
End If
Next
Application.DisplayAlerts = True
End Sub
本帖最后由 chart888 于 2017-7-7 16:41 编辑
- Sub hbrglx()
- Application.DisplayAlerts = False
- Dim i As Integer
- For i = 2 To 7
- If Cells(4, i) = Cells(5, i) Then
- Cells(4, i).Resize(2, 1).Merge
- End If
- Next
- Application.DisplayAlerts = True
- End Sub
复制代码
或者用下面的
- Sub hbrglx1()
- Application.DisplayAlerts = False
- Dim i As Integer
- For i = 2 To 7
- If Cells(4, i) = Cells(5, i) Then
- Range(Cells(4, i), Cells(5, i)).Merge
- End If
- Next
- Application.DisplayAlerts = True
- End Sub
复制代码
|
|