I am trying to sort rows of data based on an identification number. The amount of entries can change. I can use the record macro function and get this code:
Sub Macro5()
'
' Macro5 Macro
'
'
Range("B9:G67").Select
ActiveWindow.SmallScroll Down:=-66
ActiveWorkbook.Worksheets("SEC").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("SEC").Sort.SortFields.Add Key:=Range("B9:B67"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("SEC").Sort
.SetRange Range("B9:G67")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveWindow.SmallScroll Down:=48
End Sub
However, it's messy and depends on the number of entries to be identical each time. Here are some facts that will help:
1) The data always exists starting in B9. There will always be data in this row.
2)The data in column B is already stored in an array, but I'm not sure if that'll help. Likewise, all other columns have their data in separate arrays with the same indices for each row.
I'm having problems with figuring out excel's syntax for sort, but I think if it's possible to clean up the code and select b9 and all values below that (no gaps in file), it should be pretty simple code.
Thanks for any and all guidance.
Bookmarks