VBA sort by two columns and add row after first sort based on cell

slivesay

New Member
Joined
Jan 4, 2019
Messages
44
I have the below code to sort my data by color (K11:K123) and by item (C11:C123). Is there a way to have a blank row inserted (also have all formulas of all other cells) to separate when the color changes.

Range("B11:M123").Select
ActiveWindow.SmallScroll Down:=-102
ActiveWorkbook.Worksheets("Break").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Break").Sort.SortFields.Add Key:=Range("K11:K123") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Break").Sort.SortFields.Add Key:=Range("C11:C123") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Break").Sort
.SetRange Range("B11:M123")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.Apply
End With

Thank you!!
 

Some videos you may like

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

slivesay

New Member
Joined
Jan 4, 2019
Messages
44
I have figured this one out - It may be marked closed, but I do not know how to do so.

Thank you!!! :)
 

Watch MrExcel Video

Forum statistics

Threads
1,098,863
Messages
5,465,129
Members
406,414
Latest member
Discorz

This Week's Hot Topics

Top