Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 97
Default Merge cells with formula or macro?

I would like to merge cells in column A when the adjacent vertical cells are
the same. For example:

Col A
Row1 CX457
Row2 AG925
Row3 AG925
Row4 AG925
Row5 RB639
Row6 RB639

In this case A2, A3 & A4 would be merged, A5 & A6 would be merged. Is there
a way to do this automatically?

Thanks,
Joe M.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,355
Default Merge cells with formula or macro?

I'd recommend against merging cells. Why not use a conditional format and if
the cells match, have one of them change to a white font?

"Joe M." wrote:

I would like to merge cells in column A when the adjacent vertical cells are
the same. For example:

Col A
Row1 CX457
Row2 AG925
Row3 AG925
Row4 AG925
Row5 RB639
Row6 RB639

In this case A2, A3 & A4 would be merged, A5 & A6 would be merged. Is there
a way to do this automatically?

Thanks,
Joe M.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 427
Default Merge cells with formula or macro?

Merged? As in concatenated (added together to read RB639 RB639 in a
single cell)?

Or do you want to show only a single occurence if the entry occurs
multiple times?

  #4   Report Post  
Posted to microsoft.public.excel.misc
bj bj is offline
external usenet poster
 
Posts: 1,397
Default Merge cells with formula or macro?

what do you mean by merging cells?
merging can mean anything from
summing up values.
Deleting duplicates,
to formatting several cells to appear as one cell.

"Joe M." wrote:

I would like to merge cells in column A when the adjacent vertical cells are
the same. For example:

Col A
Row1 CX457
Row2 AG925
Row3 AG925
Row4 AG925
Row5 RB639
Row6 RB639

In this case A2, A3 & A4 would be merged, A5 & A6 would be merged. Is there
a way to do this automatically?

Thanks,
Joe M.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 97
Default Merge cells with formula or macro?

Sorry for not being clear. In this case, merge as to format several cells to
appear as one cell.

"bj" wrote:

what do you mean by merging cells?
merging can mean anything from
summing up values.
Deleting duplicates,
to formatting several cells to appear as one cell.

"Joe M." wrote:

I would like to merge cells in column A when the adjacent vertical cells are
the same. For example:

Col A
Row1 CX457
Row2 AG925
Row3 AG925
Row4 AG925
Row5 RB639
Row6 RB639

In this case A2, A3 & A4 would be merged, A5 & A6 would be merged. Is there
a way to do this automatically?

Thanks,
Joe M.



  #6   Report Post  
Posted to microsoft.public.excel.misc
bj bj is offline
external usenet poster
 
Posts: 1,397
Default Merge cells with formula or macro?

I have had a lotr of trouble with merged cells over the years, but a brute
force macro to do what you want would be

Sub test()
rt = 1
For r = 2 To 50000
If Cells(r, 1) = "" Then GoTo 99
If Cells(r - 1, 1) < Cells(r, 1) Then rt = r: GoTo 99
If Cells(r - 1, 1) = Cells(r + 1, 1) Then GoTo 99
If Cells(r - 1) = Cells(r, 1) Then
Range(Cells(rt, 1), Cells(r, 1)).Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
End If
99
Next r

change the formating of the merged cells as you would like them to appear

End Sub

"Joe M." wrote:

Sorry for not being clear. In this case, merge as to format several cells to
appear as one cell.

"bj" wrote:

what do you mean by merging cells?
merging can mean anything from
summing up values.
Deleting duplicates,
to formatting several cells to appear as one cell.

"Joe M." wrote:

I would like to merge cells in column A when the adjacent vertical cells are
the same. For example:

Col A
Row1 CX457
Row2 AG925
Row3 AG925
Row4 AG925
Row5 RB639
Row6 RB639

In this case A2, A3 & A4 would be merged, A5 & A6 would be merged. Is there
a way to do this automatically?

Thanks,
Joe M.

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
Macro to run formula only on cells with data Rob Excel Discussion (Misc queries) 4 March 5th 07 07:05 PM
Formula in macro or in sheet/cells? Heine Excel Worksheet Functions 10 November 3rd 06 11:02 PM
Merge =( formula should retain fraction type numbers after merge. Aubrey Excel Worksheet Functions 0 February 9th 06 07:37 PM
Excel Macro - Merge Cells unavailable - Unable to figue out why. newexceluser Excel Worksheet Functions 0 January 18th 06 03:22 PM
repeat macro formula to all cells dave glynn Excel Discussion (Misc queries) 8 March 10th 05 08:42 PM


All times are GMT +1. The time now is 07:09 PM.

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

About Us

"It's about Microsoft Excel"