Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Merge the same group of cells down a column quickly Rich F Excel Discussion (Misc queries) 9 February 12th 10 02:30 PM
Merge cells with formula or macro? Joe M. Excel Discussion (Misc queries) 5 July 23rd 07 10:28 PM
How do I merge two cells in a column AliWitt Excel Discussion (Misc queries) 1 February 9th 06 10:37 PM
How do I do a vertical merge of cells in a column? PAM Excel Discussion (Misc queries) 1 September 21st 05 06:51 PM
Merge cells using macro Tom Ogilvy Excel Programming 0 August 7th 03 07:20 PM


All times are GMT +1. The time now is 03:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"