Cell values based on comparison of previous column cell value.

Deepk

Board Regular
Joined
Mar 21, 2018
Messages
105
Office Version
  1. 2016
Platform
  1. Windows
hi All,

I want formula or macro that work on the following table and provide the value in column E. The macro should compare the sorted (a-z) value in column D and based on the value from the column C, it provide the below mentioned details in column E.

[TABLE="width: 242"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]Column C[/TD]
[TD]Column D[/TD]
[TD]Column E[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]PAPA[/TD]
[TD]1=2[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]PAPA[/TD]
[TD]1=2[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]TATA[/TD]
[TD]3=4[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]TATA[/TD]
[TD]3=4[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]TATA[/TD]
[TD]3=4[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]FEAR[/TD]
[TD]6=7[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]FEAR[/TD]
[TD]6=7[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]MAMA[/TD]
[TD]8=9[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]MAMA[/TD]
[TD]8=9[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]MAMA[/TD]
[TD]8=9[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]MAMA[/TD]
[TD]8=9[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]GHMF[/TD]
[TD]12=13[/TD]
[/TR]
[TR]
[TD]13[/TD]
[TD]GHMF[/TD]
[TD]12=13[/TD]
[/TR]
</tbody>[/TABLE]

Please help me with the code.

Thanks in advance.
 
Thank you Peter for your help.
You're welcome.

If interested, here is another macro that you could consider.
Code:
Sub JoinGroups()
  Dim c As Range
  Dim j As Long, lr As Long
  
  Set c = Range("D2")
  lr = Range("D" & Rows.Count).End(xlUp).Row
  Do Until c.Row > lr
    Do While c.Offset(j + 1).Value = c.Value
      j = j + 1
    Loop
    If j > 0 Then c.Offset(, 1).Resize(j + 1).Value = Join(Application.Transpose(c.Offset(, -1).Resize(j + 1).Value), "=")
    Set c = c.Offset(j + 1)
    j = 0
  Loop
End Sub
 
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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