vba操作excel的合并单元格代码
2007-01-25 18:14
435 查看
Sub mergeunit()
Dim spos, epos As Integer
Dim ustr, nowstr As String
spos = 1
epos = 1
ustr = Cells(1, 1)
Application.DisplayAlerts = False
Do
nowstr = Cells(epos, 1)
If nowstr <> ustr Then
Range("A" & spos & ":A" & epos - 1).Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
ustr = nowstr
End With
Selection.Merge
spos = epos
End If
epos = epos + 1
Loop While Len(nowstr) > 0
End Sub
Dim spos, epos As Integer
Dim ustr, nowstr As String
spos = 1
epos = 1
ustr = Cells(1, 1)
Application.DisplayAlerts = False
Do
nowstr = Cells(epos, 1)
If nowstr <> ustr Then
Range("A" & spos & ":A" & epos - 1).Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
ustr = nowstr
End With
Selection.Merge
spos = epos
End If
epos = epos + 1
Loop While Len(nowstr) > 0
End Sub
相关文章推荐
- VBA陈旧的代码:在VBA中操作Excel内容二
- VBA操作Excel代码收集
- Excel 文件复制操作vba代码
- Excel 2003 中如何用VBA 代码访问单元格里的值及操作单元格
- VBA处理文件框架代码 【第五部分:Excel文件操作】
- Excel 关于新建xls文件 新建sheet 合并sheet的VBA操作代码
- VBA中操作Excel的部分方法代码示例
- VBA陈旧的代码:在VBA中操作Excel内容一
- Excel 文件复制操作vba代码
- VBA中操作Excel的部分方法代码示例
- Excel与VBA编程中的常用代码
- Excel VBA常用操作整理与学习
- ★★★★Excel-VBA操作文件四大方法之四
- 【转载】jxl操作excel 字体 背景色 合并单元格 列宽等 .
- Excel-VBA操作文件四大方法
- javascript 操作Word和Excel的实现代码
- Excel VBA 基础知识――用代码读写目标单元格
- Excel-VBA操作文件四大方法之一
- java poi操作excel示例代码
- C#+VBA 操作EXCEL(转)