Row 1 spit it into 2 column

sksanjeev786

Well-known Member
Joined
Aug 5, 2020
Messages
1,019
Office Version
  1. 365
  2. 2016
Platform
  1. 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
1740170572039.png


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
 

Forum statistics

Threads
1,226,837
Messages
6,193,249
Members
453,784
Latest member
Chandni

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top