Merge filled cells with blank cells below them?

DILeak

New Member
Joined
Sep 26, 2014
Messages
1
Hello, I recently stumbled across this board and believe it might be able to make my life easier, as I am just beginning to learn the wonders of Excel. This might be a rather novice question with a very simple answer, but I have yet to find one through my searches.

Since I am bad with words, I figure that a before and after shot of what I would like to accomplish would explain much better.
I have a rather larger sheet with information ordered like so.

NG5wsOo.jpg


Now while this works, I would like it much better if I could merge each item with the blank cells below them. Like so:

K7UK5Pl.jpg


However, this is a rather large document and I simply cannot do them all manually. I have tried selecting each column, Go To Special > Blanks and merging, but of course that only merged the blanks together, and not with the information above them. I am using Excel 2013. All help is very much appreciated, thank you.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
The code will Merge cells as required in range A1:C25. Change the range as required.
Code:
Sub specialMerge()
Dim cel As Range


For Each cel In Range("A1:C25")
    
    If cel.Offset(1, 0).Value = "" Then
    Range(cel, cel.Offset(1, 0)).Merge
    cel.HorizontalAlignment = xlCenter
    cel.VerticalAlignment = xlCenter
    
   End If
Next cel
End Sub
 
Upvote 0
Welcome to the MrExcel board!

For columns A & B (1 & 2) try this in a copy of your workbook.
Rich (BB code):
Sub Merge_Cells()
  Dim blnks As Range, r As Range
  Dim c As Long
  
  For c = 1 To 2
    On Error Resume Next
    Set blnks = Columns(c).SpecialCells(xlBlanks)
    On Error GoTo 0
    If Not blnks Is Nothing Then
      For Each r In blnks.Areas
        With Union(r.Cells(0), r)
          .Merge
          .VerticalAlignment = xlCenter
        End With
      Next r
    End If
  Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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