求VBA宏代码,隔行合并单元格
12行5列,从第一行开始,隔3行合并1行,也就是把a1:e1,a4:e4,a7:e7,a10:e10,合并且第一列的数据合并后居中,谢谢各位大神!上面图丢了一行,补充一下...
12行5列,从第一行开始,隔3行合并1行,也就是把a1:e1,a4:e4,a7:e7,a10:e10,合并且第一列的数据合并后居中,谢谢各位大神!
上面图丢了一行,补充一下,以这个图为准 展开
上面图丢了一行,补充一下,以这个图为准 展开
3个回答
展开全部
Sub 隔两行合并居中()
Dim i As Long, EndR As Long
Application.DisplayAlerts = False
Application.ScreenUpdating = False
With ActiveSheet
EndR = .Cells(.Rows.Count, 1).End(xlUp).Row
For i = 1 To EndR Step 3
With .Cells(i, 1).Resize(1, 5)
.Merge
.HorizontalAlignment = xlCenter
End With
Next
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
代码如上,不明白,请追问
展开全部
Private Sub CommandButton1_Click()
Dim i%
For i = 1 To 12 Step 3
Range(Cells(i, 1), Cells(i, 5)).Select
Application.DisplayAlerts = False
Selection.Merge
Selection.HorizontalAlignment = xlCenter
Next
End Sub
Dim i%
For i = 1 To 12 Step 3
Range(Cells(i, 1), Cells(i, 5)).Select
Application.DisplayAlerts = False
Selection.Merge
Selection.HorizontalAlignment = xlCenter
Next
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询