sksanjeev786
Well-known Member
- Joined
- Aug 5, 2020
- Messages
- 1,019
- Office Version
- 365
- 2016
- Platform
- Windows
Hi
I need row 1 to split into 2 columns and need same name in both the column
so Khansai Gen Z or Millennail will be on column 2,3 instead of merge colum and same for other column
I need row 1 to split into 2 columns and need same name in both the column
so Khansai Gen Z or Millennail will be on column 2,3 instead of merge colum and same for other column
VBA Code:
Sub SplitFirstRowBasedOnSecondRow()
Dim slide As slide
Dim shape As shape
Dim tbl As Table
Dim colIndex As Integer
Dim totalCols As Integer
Dim i As Integer
Set slide = ActivePresentation.Slides(Application.ActiveWindow.View.slide.slideIndex)
If Application.ActiveWindow.Selection.Type <> ppSelectionShapes Then
MsgBox "Please select a table.", vbExclamation, "No Table Selected"
Exit Sub
End If
Set shape = Application.ActiveWindow.Selection.ShapeRange(1)
If Not shape.HasTable Then
MsgBox "Selected shape is not a table.", vbExclamation, "Error"
Exit Sub
End If
Set tbl = shape.Table
totalCols = tbl.Columns.Count
For colIndex = totalCols To 1 Step -1
If tbl.cell(2, colIndex).MergeCells Then
tbl.cell(1, colIndex).MergeCells = False
End If
Next colIndex
MsgBox "Row 1 has been split based on Row 2!", vbInformation, "Success"
End Sub