Hi, I am trying to write a macro that will look at a section of data, sort the data until it hits a blank cell and then move the newly sorted data to another location. Column C is random numbers for random sorting. The data is in column D. The data could range from 1 cell to 35 cells. I can't figure out how to make the sort variable, like I can the moving using the xlDown thing.
Here's what I have so far. It is currently showing C65:D87 because that's what ended up there when I recorded the macro. Thanks for any help on this!
Sub Macro9()
'
' Macro9 Macro
'
'
range("C65:D65").Select
range("D65:D65").Activate
range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("SkillCards").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("SkillCards").Sort.SortFields.Add Key:=range( _
"C65:C87"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("SkillCards").Sort
.SetRange range("C65:D87")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
range("D65").Select
range(Selection, Selection.End(xlDown)).Select
Selection.Copy
range("D3").Select
ActiveSheet.Paste
range("D65").Select
range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.ClearContents
range("D3").Select
End Sub
Bookmarks