返回列表 上一主題 發帖

關於跨欄置中和框線畫線是否有比較簡易的寫法(謝謝各位大大,已解決。)

關於跨欄置中和框線畫線是否有比較簡易的寫法(謝謝各位大大,已解決。)

本帖最後由 av8d 於 2012-4-27 08:12 編輯

首先A1:H1和A2:H2欄取消跨欄置中
  1.     Range("A1:G1").Select
  2.     With Selection
  3.         .HorizontalAlignment = xlCenter
  4.         .VerticalAlignment = xlCenter
  5.         .WrapText = False
  6.         .Orientation = 0
  7.         .AddIndent = False
  8.         .IndentLevel = 0
  9.         .ShrinkToFit = False
  10.         .ReadingOrder = xlContext
  11.         .MergeCells = False
  12.     End With
  13.     Selection.Merge
  14.     Range("A2:G2").Select
  15.     With Selection
  16.         .HorizontalAlignment = xlCenter
  17.         .VerticalAlignment = xlCenter
  18.         .WrapText = False
  19.         .Orientation = 0
  20.         .AddIndent = False
  21.         .IndentLevel = 0
  22.         .ShrinkToFit = False
  23.         .ReadingOrder = xlContext
  24.         .MergeCells = False
  25.     End With
  26.     Selection.Merge
  27. End Sub
複製代碼
然後是A1:G1和A2:G2跨欄置中
  1.     Range("A1:H1").Select
  2.     With Selection
  3.         .HorizontalAlignment = xlGeneral
  4.         .VerticalAlignment = xlCenter
  5.         .WrapText = False
  6.         .Orientation = 0
  7.         .AddIndent = False
  8.         .IndentLevel = 0
  9.         .ShrinkToFit = False
  10.         .ReadingOrder = xlContext
  11.         .MergeCells = True
  12.     End With
  13.     Selection.UnMerge
  14.     Range("A2:H2").Select
  15.     With Selection
  16.         .HorizontalAlignment = xlGeneral
  17.         .VerticalAlignment = xlCenter
  18.         .WrapText = False
  19.         .Orientation = 0
  20.         .AddIndent = False
  21.         .IndentLevel = 0
  22.         .ShrinkToFit = False
  23.         .ReadingOrder = xlContext
  24.         .MergeCells = True
  25.     End With
  26.     Selection.UnMerge
複製代碼
然後A1:G2框線畫右線
  1.     Range("A1:G2").Select
  2.     Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  3.     Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  4.     With Selection.Borders(xlEdgeLeft)
  5.         .LineStyle = xlContinuous
  6.         .ColorIndex = 0
  7.         .TintAndShade = 0
  8.         .Weight = xlThin
  9.     End With
  10.     With Selection.Borders(xlEdgeTop)
  11.         .LineStyle = xlContinuous
  12.         .ColorIndex = 0
  13.         .TintAndShade = 0
  14.         .Weight = xlThin
  15.     End With
  16.     With Selection.Borders(xlEdgeBottom)
  17.         .LineStyle = xlContinuous
  18.         .ColorIndex = 0
  19.         .TintAndShade = 0
  20.         .Weight = xlThin
  21.     End With
  22.     With Selection.Borders(xlEdgeRight)
  23.         .LineStyle = xlContinuous
  24.         .ColorIndex = 0
  25.         .TintAndShade = 0
  26.         .Weight = xlThin
  27.     End With
  28.     Selection.Borders(xlInsideVertical).LineStyle = xlNone
  29.     With Selection.Borders(xlInsideHorizontal)
  30.         .LineStyle = xlContinuous
  31.         .ColorIndex = 0
  32.         .TintAndShade = 0
  33.         .Weight = xlThin
  34.     End With
  35. End Sub
複製代碼

        靜思自在 : 脾氣嘴巴不好,心地再好也不能算是好人。
返回列表 上一主題