|
发表于 2013-8-1 10:41
|
显示全部楼层
本楼为最佳答案
qinhuan66 发表于 2013-8-1 10:34
老师;经测试取消A1单元格合并也不行。谢谢
加一句 on error goto 100就好了- Sub 单独自动填充单元格B列()
- Range("A3:B1000").Select
- With Selection
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlBottom
- End With
- With Selection '垂直居中
- .HorizontalAlignment = xlCenter '垂直居中
- .VerticalAlignment = xlCenter '垂直居中
- On Error GoTo 100
- End With '垂直居中
- Range("A2").CurrentRegion.Borders.LineStyle = 1 '加边框
- Range("B3:B1000").Select
- With Selection
- .HorizontalAlignment = xlLeft
- .VerticalAlignment = xlCenter
- .ReadingOrder = xlContext
- .MergeCells = False
- End With
- Range("A3").Select '以上代码为居中对齐表格,以下代码是自动填充表格
- Dim i As Integer, j As Long, b As String
- For i = 1 To 2
- For j = 3 To Sheet1.[D65536].End(xlUp).Row
- If Sheet1.Cells(j, i) <> "" Then
- b = Sheet1.Cells(j, i)
- Else
- Sheet1.Cells(j, i) = b
- End If
- Next j
- Next i
- 100:
- End Sub
复制代码 |
评分
-
查看全部评分
|