VBA Code:
Sub MagicNumber()
Dim wsSource As Worksheet
Dim wsDest As Worksheet
Set wsSource = ThisWorkbook.Worksheets("Form")
Set wsDest = ThisWorkbook.Worksheets("Number")
Application.ScreenUpdating = False
On Error Resume Next
With wsDest.Range("N" & wsDest.Rows.Count).End(xlUp).Offset(1, 0)
.Value = wsSource.Range("C3").Value
.Offset(0, 1).Value = wsSource.Range("C7").Value
.Offset(0, 2).Value = wsSource.Range("C5").Value
.Offset(0, 3).Value = wsSource.Range("C6").Value
.Offset(0, 4).Value = wsSource.Range("C17").Value
.Offset(0, 5).Value = wsSource.Range("C18").Value
.Offset(0, 6).Value = Round(wsSource.Range("F22").Value * 1440, 0)
.Offset(0, 7).Value = wsSource.Range("C14").Value
End With
ActiveWorkbook.Worksheets("Number").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Number").AutoFilter.Sort.SortFields.Add2 Key _
:=Range("AC1:AC2"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Number").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Application.ScreenUpdating = True
End Sub
I have this code to add some data to my list that I then sort using filter
For some reason after the macro is run cells N3:AC81 are selected yet data only goes to row 53..
I don't want anything selected.
it wasn't selected before the macro runs.
How do I get it to not select the cells? im guessing the auto filter does it?
also
Is there a better way to sort?
is there a better way to copy the data across?