vba code to sort on other-new sheet

Myproblem

Board Regular
Joined
May 24, 2010
Messages
198
i need to sort some table, report in the way to get other table with sorted result.
like: in some worksheet i created check sums, and with if functions I made TRUE FALSE column, meaning if it is true it is ok, and no need to watch any kind of differences, but if it is FALSE I need to sort just FALSE items and make report to my boss, but without TRUE items and on other -new sheet

any tips
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
i need to sort some table, report in the way to get other table with sorted result.
like: in some worksheet i created check sums, and with if functions I made TRUE FALSE column, meaning if it is true it is ok, and no need to watch any kind of differences, but if it is FALSE I need to sort just FALSE items and make report to my boss, but without TRUE items and on other -new sheet

any tips

I found this code, but i do not know that is wrong, i do not get any result



Sub SortViaWorksheet() Dim Arr(1 To 5) As String ' this is the array to be sorted Dim WS As Worksheet ' temporary worksheet Dim R As Range Dim N As Long ' fill up the array with some ' aribtrary values. Arr(1) = "aaa" Arr(2) = "zzz" Arr(3) = "mmm" Arr(4) = "ttt" Arr(5) = "bbb" Application.ScreenUpdating = False ' create a new sheet Set WS = ThisWorkbook.Worksheets.Add ' put the array values on the worksheet Set R = WS.Range("A1").Resize(UBound(Arr) - LBound(Arr) + 1, 1) R = Application.Transpose(Arr) ' sort the range R.Sort key1:=R, order1:=xlAscending, MatchCase:=False ' load the worksheet values back into the array For N = 1 To R.Rows.Count Arr(N) = R(N, 1) Next N ' delete the temporary sheet Application.DisplayAlerts = False WS.Delete Application.DisplayAlerts = True Application.ScreenUpdating = True ' test/debug/confirmation For N = LBound(Arr) To UBound(Arr) Debug.Print Arr(N) Next N End Sub


any help
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,134
Members
452,890
Latest member
Nikhil Ramesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top