You can try something like this. This code swaps to ranges of cells.
Sub sortRange()
myend = 100
For I = 0 To (myend - 1)
For j = (I + 1) To myend
Set FirstRange = _
Range("A1:P4").Offset(Rowoffset:=4 * I, columnoffset:=0)
Set SecondRange = _
Range("A1:P4").Offset(Rowoffset:=4 * (j + 1), columnoffset:=0)
FirstRange.Select
FirstRange.Cut
SecondRange.Select
SecondRange.Insert (xlShiftDown)
If (I + 1 < j) Then
Set FirstRange = _
Range("A1:P4").Offset(Rowoffset:=4 * I, columnoffset:=0)
Set SecondRange = _
Range("A1:P4").Offset(Rowoffset:=4 * (j - 1), columnoffset:=0)
End If
FirstRange.Select
FirstRange.Cut
SecondRange.Select
SecondRange.Insert (xlShiftDown)
Next j
Next I
End Sub
"Aria" wrote:
Hello,
I'm perplexed on how to go about solving a Sorting problem in code. I
have a group of rows with data listed across the columns ie.
Row 3, Employee Name, [Name Input], Sales Yr, Jan, Feb, Mar,
...etc,Total.
Row 4, Employee Number, [Number Input], Sales Yr, Jan, Feb, Mar, ...etc,
Total.
Row 5, Employee Status, [Status Input], Sales Yr, Jan, Feb, Mar, ...etc,
Total.
Row 6, Other Info, [Info Input], Sales Yr, Jan, Feb, Mar, ...etc, Total.
This segment of data gets repeated down the sheet for each employee. Is
there a way to sort by choosing the [Name Input] or by [Number Input]
and keep each segment together?
Thanks so much,
Aria :)
*** Sent via Developersdex http://www.developersdex.com ***