DPChristman
New member
- Joined
- Sep 1, 2016
- Messages
- 5
- Reaction score
- 0
- Points
- 0
I was given this macro by user JoeMo at MrExcel forum, and it proved very helpful at automatically putting three empty rows between groups of data in a large spreadsheet.
Link: http://www.mrexcel.com/forum/excel-questions/962316-help-macro-sort-issue.html
However, I now have a problem where the macro re-sorts the data by district only (column B), rather than first by zone (column A), then district, and then store (column C)
Since the district numbers do not always fall into the logical zones, this is a problem
Example: district 101 is in zone 10, but district 133 is also in zone 10, and not in Zone 13, which is where it would logically fall.
As a result, doing summaries by District and Zone is difficult to do, and follow.
The original thread can be found by searching the phrase Splitting Data into Districts on the MrExcel forum
Link: http://www.mrexcel.com/forum/excel-questions/962316-help-macro-sort-issue.html
However, I now have a problem where the macro re-sorts the data by district only (column B), rather than first by zone (column A), then district, and then store (column C)
Since the district numbers do not always fall into the logical zones, this is a problem
Example: district 101 is in zone 10, but district 133 is also in zone 10, and not in Zone 13, which is where it would logically fall.
As a result, doing summaries by District and Zone is difficult to do, and follow.
The original thread can be found by searching the phrase Splitting Data into Districts on the MrExcel forum
Code:
[COLOR=#333333]'[/COLOR]
[COLOR=#333333]' ThreeRowsBetween Macro[/COLOR]
[COLOR=#333333]'[/COLOR]
[COLOR=#333333]Dim i As Long[/COLOR]
[COLOR=#333333]Application.ScreenUpdating = False[/COLOR]
[COLOR=#333333]With Rows(7)[/COLOR]
[COLOR=#333333].Insert[/COLOR]
[COLOR=#333333].Offset(-1, 0).RowHeight = 1[/COLOR]
[COLOR=#333333]End With[/COLOR]
[COLOR=#333333]Range("A8").CurrentRegion.SORT key1:=[b2], order1:=xlAscending, Header:=xlYes[/COLOR]
[COLOR=#333333]For i = Range("B8:B" & Cells(Rows.Count, "B").End(xlUp).Row).Rows.Count To 10 Step -1[/COLOR]
[COLOR=#333333]If Cells(i, "B") <> Cells(i - 1, "B") Then[/COLOR]
[COLOR=#333333]Cells(i, "B").Resize(3, 1).EntireRow.Insert[/COLOR]
[COLOR=#333333]End If[/COLOR]
[COLOR=#333333]Next i[/COLOR]
[COLOR=#333333]Rows(7).Delete[/COLOR]
[COLOR=#333333]Application.ScreenUpdating = True[/COLOR]
[COLOR=#333333]End Sub[/COLOR]
Last edited by a moderator: