Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Merge Cells in a column Macro
Experts & Gurus:
I need to merge cells in a column that have exactly the same information. For example, cells E2, E3, and E4 have the same information. Existing spreadsheet: A B C D E F 1 aa ss dd ff gg hh 2 qq ww ee rr tt yy 3 cc vv bb nn tt mm 4 hh uu ii oo tt kk Desired speadsheet: A B C D E F 1 aa ss dd ff gg hh 2 qq ww ee rr yy 3 cc vv bb nn tt mm 4 hh uu ii oo kk I will sort column E, then I want the macro to look in column E and if 2 or more cells are the same I want the cells to merge. Your help is appreciated! Best regards, Mike |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Merge Cells in a column Macro
Hi
try the following macro for column E: Sub merge_cells() Dim lastrow As Long Dim row_index As Long Dim start_index As Long Dim wks As Worksheet Set wks = ActiveSheet With wks lastrow = .Cells(Rows.Count, "E").End(xlUp).Row start_index = 1 For row_index = 2 To lastrow + 1 If .Cells(row_index, 5).Value < .Cells(row_index - 1, 5).Value Then If row_index - start_index 1 Then Application.DisplayAlerts = False With Range(.Cells(start_index, 5), .Cells(row_index - 1, 5)) .Merge .VerticalAlignment = xlCenter End With Application.DisplayAlerts = True End If start_index = row_index End If Next End With End Sub -- Regards Frank Kabel Frankfurt, Germany Mike G. wrote: Experts & Gurus: I need to merge cells in a column that have exactly the same information. For example, cells E2, E3, and E4 have the same information. Existing spreadsheet: A B C D E F 1 aa ss dd ff gg hh 2 qq ww ee rr tt yy 3 cc vv bb nn tt mm 4 hh uu ii oo tt kk Desired speadsheet: A B C D E F 1 aa ss dd ff gg hh 2 qq ww ee rr yy 3 cc vv bb nn tt mm 4 hh uu ii oo kk I will sort column E, then I want the macro to look in column E and if 2 or more cells are the same I want the cells to merge. Your help is appreciated! Best regards, Mike |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Merge the same group of cells down a column quickly | Excel Discussion (Misc queries) | |||
Merge cells with formula or macro? | Excel Discussion (Misc queries) | |||
How do I merge two cells in a column | Excel Discussion (Misc queries) | |||
How do I do a vertical merge of cells in a column? | Excel Discussion (Misc queries) | |||
Merge cells using macro | Excel Programming |