Sie sind auf Seite 1von 4

Unmerging excel rows, and duplicate data

Ask Question
Asked 7 years, 6 months ago
Active 1 month ago
Viewed 51k times
27

I have been given a fairly large database stored in Microsoft Excel, which I have to try convert
into something useful.
However, one of the problems that I am encountering is that some of the data is merged together
(horizontally in 2s).

For example;

row 1: [ x ][ x ][ x ][ x ][ x ]
row 2: [ x ][ x ][ o o ][ x ]
row 3: [ o o ][ x ][ o o ]

Where x's are single cells and o's are merged together

What I want to do is unmerge all the rows (which I could do fairly easy with the unmerge
button), but for where the merged cell was, have the data duplicated across the 2 cells.
From; [[ Some Data ]]
To; [ Some Data ][ Some Data ]

Thanks! Any help is appreciated.

excel vba excel-vba


share

improve this question


edited Jan 17 '17 at 11:20

eye_mew
3,48777 gold badges2020 silver badges3737 bronze badges
asked Feb 9 '12 at 16:45

H3katonkheir
19911 gold badge33 silver badges1515 bronze badges
add a comment

4 Answers
active oldest votes
46

This is a VBA solution. This macro will search every cell in the active sheet to see if they are
merged. If they are, it stores the range of the merged cells in a temp. range variable, unmerges
the cells, then fills the range with the value of the first cell in the unmerged range (what the value
was).

Sub UnMergeFill()

Dim cell As Range, joinedCells As Range

For Each cell In ThisWorkbook.ActiveSheet.UsedRange


If cell.MergeCells Then
Set joinedCells = cell.MergeArea
cell.MergeCells = False
joinedCells.Value = cell.Value
End If
Next

End Sub
share

improve this answer


edited Aug 22 '13 at 0:55
answered Feb 9 '12 at 16:59

aevanko
12.9k33 gold badges4545 silver badges5353 bronze badges

 Thank you, it worked perfectly! Took a look around to figure out how VBA could be
executed. – H3katonkheir Feb 9 '12 at 18:39
 You're welcome (and sorry for not adding that info for ya)! – aevanko Feb 10 '12 at 4:40
 1

Issun, I only used one line in my own VBA which is "cell.MergeCells = False", that was all and does the
trick for me several times a year. It un-merges every cell without checking each cell first. – Robert Ilbrink
Feb 10 '12 at 16:40
 The point of checking it is to set the range so that you can fill in all the unmerged cells
with the same value since unmerge just puts the value in the first cell and makes the
others blank (the issue the OP had) – aevanko Feb 10 '12 at 17:51

add a comment
14

1. Select the range which has merged data


2. Click on Merge and Centre to unmerge cells
3. Select the range of data again
4. Press Ctrl+G > Special > Blanks
5. Press = and up arrow key
6. Press Ctrl+Enter

share

improve this answer


answered Apr 14 '15 at 15:59

montells
3,50233 gold badges3737 silver badges4646 bronze badges
add a comment
3

You don't need VBA for something like that.

1. Select the range of the merged cells


2. Unmerge the cells
3. Home -> Find and Select -> Go to special... -> Blanks -> ok
4. Type "=" move one cell up and press Ctrl + Enter

If R1C1 styles are enabled from: File -> Options -> Formula -> R1C1 Reference style then

1. ...
2. ...
3. ...
4. Type "=R[-1]c" and press Ctrl + Enter
How to remove Excel 2007 Formula and keep
data

https://www.youtube.com/watch?v=8mk2QZnLiG0

In this video tutorial we will show you how to remove excel formula and keep data. In order to remove
excel formula and keep the data, open Microsoft Excel. For example, in A1 cell type 5. In B1 cell type 6.
In C1 cell type "=A1+B1". Now, to remove formula and keep the data, select C1 cell and click "Copy" in
the "Home" tab. Right-click on C1 cell and choose "Paste special". In the Paste Special pop-up window
choose "Values" and press "ok".

Das könnte Ihnen auch gefallen