Unmerge all cells
Unmerges all the merged cells in the active worksheet.
This macro was converted from VBA code using the AI plugin.
(function(){
// Get the active sheet
var oWorksheet = Api.GetActiveSheet();
// Get all cells in the worksheet by getting the used range
var oUsedRange = oWorksheet.GetUsedRange();
// Check if there is any used range
if (oUsedRange) {
// Unmerge all cells in the used range
oUsedRange.UnMerge();
}
// Alternative approach: Get the entire sheet range and unmerge
// This ensures all possible merged cells are unmerged
var oRange = oWorksheet.GetRange("A1:XFD1048576");
oRange.UnMerge();
})();
Methods used: GetActiveSheet, GetUsedRange, UnMerge, GetRange
Reference Microsoft VBA macro code
Sub UnmergeAllCells()
ActiveSheet.Cells.UnMerge
End Sub
Result