0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PowerPoint 表の操作 セルの結合と分割で遊ぶ

Posted at

なんか試しにいろいろいじってたら妙な表ができたのでなんとなくまとめた

テキトーに表を入れる
image.png

これを選択してUnMergeCellを何度か実行していくとこうなる
image.png

MergeCellを繰り返すともとに戻せる
image.png

コード(標準モジュール)

Sub MergeCell()
  Call Table上のセルのマージ(1, 1, 2, 3)
End Sub
Sub UnMergeCell()
  Call Table上のセルの分割(1, 1, 2, 3)
End Sub
Sub Table上のセルのマージ(R1 As Long, C1 As Long, RLast As Long, CLast As Long)
  On Error GoTo ErrLabel
  Dim tbl操作対象 As Table
  With ActiveWindow.Selection
    
    If .Type = ppSelectionNone Or _
    .Type = ppSelectionSlides Then Exit Sub
    
    Set tbl操作対象 = .ShapeRange.Table
    
  End With
  
  With tbl操作対象
    
    .Cell(R1, C1).Merge _
      MergeTo:=.Cell(RLast, CLast)
    
  End With
  Exit Sub
ErrLabel:
  With Err
    MsgBox "エラーNo:" & .Number & vbLf & .Description
  End With
End Sub

Sub Table上のセルの分割(R1 As Long, C1 As Long, 分割数 As Long, 分割数C As Long)
  On Error GoTo ErrLabel
  Dim tbl操作対象 As Table
  With ActiveWindow.Selection
    
    If .Type = ppSelectionNone Or _
    .Type = ppSelectionSlides Then Exit Sub
    
    Set tbl操作対象 = .ShapeRange.Table
    
  End With
  
  With tbl操作対象
    
    .Cell(R1, C1).Split 分割数, 分割数C
    
  End With
  Exit Sub
ErrLabel:
  With Err
    MsgBox "エラーNo:" & .Number & vbLf & .Description
  End With
End Sub
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?