Littlemalky
Board Regular
- Joined
- Jan 14, 2011
- Messages
- 223
Ok, so I have a large set of data that I sort with some code initially and do some other stuff to. Secondly, I have code to insert a break in rows between a range of numbers (this is shown below). Now, that the data is broken up in two portions (an upper, and lower portion), I need to resort the top portion of the data relative to column "V" in ascending order, without touching the top portion. The amount of data changes every week so the ranges are not static, except for the columns, they are always static as I have data A:V. My code to sort the data after the rows are inserted is not working for me because it grabs everything instead of just the top portion of data. Can someone help me adjust this after the rows are inserted.
Code:
Private Sub Insert_Rows() 'Inserts break between 3 & 4 days late
Dim Found As Range
Dim counter As Long, sMax As Long
sMax = Application.Max(Range("S:S"))
counter = 4
Do
Set Found = Range("S:S").Find(counter, Range("S1"), xlValues, xlWhole, xlByRows, xlNext)
If Not Found Is Nothing Then Found.Resize(4).EntireRow.Insert
counter = counter + 1
Loop Until Not Found Is Nothing Or counter > sMax
'If Found Is Nothing Then MsgBox "Can't find four or larger."
End Sub
Private Sub SecondSort()
Dim lRow As Long
With Worksheets("detail w add")
lRow = .UsedRange.Row + .UsedRange.Rows.Count - 1
.Range("A1", Cells(lRow, "V")).Sort _
Key1:=.Columns("V"), _
Order1:=xlDescending, _
Header:=xlYes
End With
End Sub