Consulting

Results 1 to 7 of 7

Thread: Solved: Unmerge cells & Auto-fills

  1. #1

    Solved: Unmerge cells & Auto-fills

    Hi

    1. I have a spread sheet with many cells merged, I am looking for a macro that will automatically unmerge all the cells.

    2. When I unmerge the cells, only the first cell will be filled with the original text, all the others are just empty cells. What I needed is to auto-fill the unmerged empty cells with the corresponding texts from the original merged cells.

    Any help would be appreciated

    Cheers Guys

  2. #2
    VBAX Regular
    Joined
    Dec 2004
    Posts
    92
    Location
    That's what happens anyway...by default. Select the range you want to unmerge, or select the whole sheet by clicking the upper left corner box next to the column header and above the row header. Click the merge button and all the cells should unmerge, leaving the text in the upper left cell of the original merged cells.

  3. #3
    Quote Originally Posted by jproffer
    That's what happens anyway...by default. Select the range you want to unmerge, or select the whole sheet by clicking the upper left corner box next to the column header and above the row header. Click the merge button and all the cells should unmerge, leaving the text in the upper left cell of the original merged cells.
    Thank you for your reply. I am aware of what you said.
    I am looking for a macro that do the job for me instead of copy/paste every cell emptied after unmerge.

  4. #4
    VBAX Regular
    Joined
    Dec 2004
    Posts
    92
    Location
    OK....now I don't know what you mean. I apologize, maybe it's me...but I don't get it.

    If you unmerge several cells that contain a value, or text or whatever...the upper left cell will take on that value, text or whatever...by default. No copy and paste needed...just unmerge, 2 clicks and you can unmerge a whole worksheet.

    I'm not following why you think you have to copy and paste anything after you unmerge.

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    syybacon, attached is a workbook with code that does what jproffer kindly suggested. What do you mean by copy paste every cell emptied after the unmerge?

    You suggest that you want the unused portion of the now unmerged cells filled with the corresponding text from the original merged cells.... Please post an example.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  6. #6
    Thank you vey much for your reply. I have found a solution in a previous thread.

    Public Sub ProcessData()
    Dim cell As Range
    Dim MergedCell As Range
    Dim NumRows As Long
    Dim NumCols As Long

    With Application

    .ScreenUpdating = False
    .Calculation = xlCalculationManual
    End With

    With ActiveSheet

    For Each cell In Range("A1").Resize( _
    .Cells.SpecialCells(xlCellTypeLastCell).Row, _
    .Cells.SpecialCells(xlCellTypeLastCell).Column)

    If cell.MergeCells Then

    NumRows = cell.MergeArea.Rows.Count
    NumCols = cell.MergeArea.Columns.Count
    cell.UnMerge
    If NumRows > 1 Then cell.AutoFill cell.Resize(NumRows)
    If NumCols > 1 Then cell.Resize(NumRows).AutoFill cell.Resize(NumRows, NumCols)
    End If
    Next cell
    End With

    With Application

    .Calculation = xlCalculationAutomatic
    .ScreenUpdating = True
    End With

    End Sub

  7. #7
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    Quote Originally Posted by syybacon
    I am looking for a macro that do the job for me instead of copy/paste every cell emptied after unmerge.
    What has your solution got to do with this part of your request?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •