Results 1 to 3 of 3

Thread: Merged cells problem

  1. #1

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Merged cells problem

    I've got a spreadsheet with loads of merged cells in it.

    All merges are 1 column wide but any number of rows long.

    I want to unmerge each one and fill each of its constituents with its text. In other words

    instead of...

    Hello

    I want...

    Hello
    Hello
    Hello
    Hello
    Hello
    Hello

    Any ideas about what the code would be. I haven't much VBA knowledge, since VB proper is my normal weapon of choice. Not used to excel programming.

    Cheers.
    I don't live here any more.

  2. #2
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591
    I think this should work.

    VB Code:
    1. Sub UnmergeAllWithFill()
    2.     For Each c In ActiveSheet.Range("A1:" & ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Address)
    3.         If c.MergeCells Then
    4.             Set rngMerged = c.MergeArea
    5.             rngMerged.UnMerge
    6.             rngMerged.Value = rngMerged.Cells(1, 1).Value
    7.         End If
    8.     Next c
    9. End Sub

  3. #3

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    Excellent (please excuse the awful pun)

    Nice one, that works fine.

    Cheers.

Posting Permissions

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



Click Here to Expand Forum to Full Width