ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Conditional sort (https://www.excelbanter.com/excel-programming/327183-conditional-sort.html)

broogle

Conditional sort
 
Let say I have 2 Columns (A = Section, B=Class).
Section Class Value
Section1 A 1
Section2 B 1
Section3 A 1
Section2 D 1
Section1 B 1
Section2 A 1
Section1 B 1
Section1 E 1
Section1 A 1
Section2 A 1

The result I want is :
Column A,B, C - is sorted, but if Section and Class is the same, only
one will be displayed and the value is added in column C.
The result will be :

Section Class Value
Section1 A 2
Section1 B 2
Section1 E 1
Section2 A 2
Section2 B 1
Section2 D 1
Section3 A 1

Would apreciate your help.
Thanks


OJ[_2_]

Conditional sort
 
Have a look at pivot tables...that should do what you want.

OJ


Patrick Molloy[_2_]

Conditional sort
 
' assum,es tabel in C1-Enn

Option Explicit
Sub Sections()
Dim index
With Range(Range("C1"), Range("E1").End(xlDown))

.Sort Key1:=Range("C2"), Order1:=xlAscending, _
Key2:=Range("D2"), Order2:=xlAscending, _
Header:=xlGuess
For index = Range("E1").End(xlDown).Row To 3 Step -1
If Cells(index, "C") = Cells(index - 1, "C") Then
If Cells(index, "D") = Cells(index - 1, "D") Then
Cells(index - 1, "E") = Cells(index - 1, "E") +
Cells(index, "E")
Rows(index).Delete
End If
End If
Next

End With

End Sub

"broogle" wrote:

Let say I have 2 Columns (A = Section, B=Class).
Section Class Value
Section1 A 1
Section2 B 1
Section3 A 1
Section2 D 1
Section1 B 1
Section2 A 1
Section1 B 1
Section1 E 1
Section1 A 1
Section2 A 1

The result I want is :
Column A,B, C - is sorted, but if Section and Class is the same, only
one will be displayed and the value is added in column C.
The result will be :

Section Class Value
Section1 A 2
Section1 B 2
Section1 E 1
Section2 A 2
Section2 B 1
Section2 D 1
Section3 A 1

Would apreciate your help.
Thanks




All times are GMT +1. The time now is 12:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com