What is the smartest way for this scenario?

prabha_friend

Board Regular
Joined
Jun 28, 2011
Messages
95
[TABLE="width: 1567"]
<tbody>[TR]
[TD]AU
[/TD]
[TD]AU
[/TD]
[TD]AU
[/TD]
[TD]AU
[/TD]
[TD]AU
[/TD]
[TD]AU
[/TD]
[TD]AU
[/TD]
[TD]AU
[/TD]
[TD]AU
[/TD]
[TD]AU
[/TD]
[TD]BD
[/TD]
[TD]BD
[/TD]
[TD]BD
[/TD]
[TD]BD
[/TD]
[TD]BD
[/TD]
[TD]BD
[/TD]
[TD]BD
[/TD]
[/TR]
[TR]
[TD]Agents
[/TD]
[TD]Agents
[/TD]
[TD]Cash Application
[/TD]
[TD]Cash Application
[/TD]
[TD]Collections
[/TD]
[TD]Collections
[/TD]
[TD]Credit Application
[/TD]
[TD]Credit Application
[/TD]
[TD]Customer Master
[/TD]
[TD]Customer Master
[/TD]
[TD]Agents
[/TD]
[TD]Agents
[/TD]
[TD]Cash Application
[/TD]
[TD]Cash Application
[/TD]
[TD]Collections
[/TD]
[TD]Collections
[/TD]
[TD]Credit Application
[/TD]
[/TR]
[TR]
[TD]Internal
[/TD]
[TD]External
[/TD]
[TD]Internal
[/TD]
[TD]External
[/TD]
[TD]Internal
[/TD]
[TD]External
[/TD]
[TD]Internal
[/TD]
[TD]External
[/TD]
[TD]Internal
[/TD]
[TD]External
[/TD]
[TD]Internal
[/TD]
[TD]External
[/TD]
[TD]Internal
[/TD]
[TD]External
[/TD]
[TD]Internal
[/TD]
[TD]External
[/TD]
[TD]Internal
[/TD]
[/TR]
</tbody>[/TABLE]
Has to Merge and Center the recurring cells Dynamically...
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Code:
Sub Mac4()
Do Until ActiveCell <> ActiveCell.Next
    Union(Selection, ActiveCell.Next).Select
    Selection.Cells(Selection.Cells.Count).Activate
    If Selection.Cells(Selection.Cells.Count) <> ActiveCell.Next Then
        DisplayAlerts = False
        Selection.Merge
        DisplayAlerts = True
        Selection.Cells(Selection.Cells.Count).Next.Activate 'Union brings the first cell as activecell
    End If
Loop
End Sub
Why not preference like Do Until ActiveCell <> ActiveCell.Next in Usedrange. Otherwise How to restrict this around only the usedrange?
 
Upvote 0
here is the code to get the column number based on your requirements but i haven't understood what exactly you want to merge can you post example how it should look afterwards.

Code:
Sub pra()
For i = 1 To Range("A1").End(xlToRight).Column
j = i
Do
 i = i + 1
Loop Until Cells(1, i).Value <> Cells(1, i + 1).Value Or Cells(2, i).Value <> Cells(2, i + 1).Value
Next i
End Sub
 
Upvote 0
[TABLE="width: 1916"]
<tbody>[TR]
[TD="colspan: 10"]AU
[/TD]
[TD="colspan: 10"]BD
[/TD]
[/TR]
[TR]
[TD="colspan: 2"]Agents
[/TD]
[TD="colspan: 2"]Cash Application
[/TD]
[TD="colspan: 2"]Collections
[/TD]
[TD="colspan: 2"]Credit Application
[/TD]
[TD="colspan: 2"]Customer Master
[/TD]
[TD="colspan: 2"]Agents
[/TD]
[TD="colspan: 2"]Cash Application
[/TD]
[TD="colspan: 2"]Collections
[/TD]
[TD="colspan: 2"]Credit Application
[/TD]
[TD="colspan: 2"]Customer Master
[/TD]
[/TR]
[TR]
[TD]Internal
[/TD]
[TD]External
[/TD]
[TD]Internal
[/TD]
[TD]External
[/TD]
[TD]Internal
[/TD]
[TD]External
[/TD]
[TD]Internal
[/TD]
[TD]External
[/TD]
[TD]Internal
[/TD]
[TD]External
[/TD]
[TD]Internal
[/TD]
[TD]External
[/TD]
[TD]Internal
[/TD]
[TD]External
[/TD]
[TD]Internal
[/TD]
[TD]External
[/TD]
[TD]Internal
[/TD]
[TD]External
[/TD]
[TD]Internal
[/TD]
[TD]External
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,222,833
Messages
6,168,523
Members
452,194
Latest member
Lowie27

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