sort the pairs

have an list of numbres  in pair

need sort  this order  2 4 6 8 9 0

after click an button need see the result in column E

Thanks in advanced
and Very Happy New Year!!
54565758.xlsx
ACCOUNTING ASSISTANTAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Business Systems Analyst , ex-Senior Application EngineerCommented:
try customize this:

``````Sub test()
Dim StartRow As Integer, LastRow As Integer, tmpArr() As String, idx As Integer
StartRow = 7
LastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "B").End(xlUp).Row

'Clear cells
ActiveSheet.Range("E" & StartRow & ":E" & LastRow).Cells.Clear

idx = 0

For i = StartRow To LastRow + 1
If ActiveSheet.Cells(i, "B") = "" Then
CustomeSortArray tmpArr
ActiveSheet.Cells(i - 1, "E") = "'" & Join(tmpArr, "")
idx = 0
ReDim tmpArr(idx)
Else
ReDim Preserve tmpArr(idx)
tmpArr(idx) = ActiveSheet.Cells(i, "B")
idx = idx + 1
End If
Next i
End Sub

Function CustomeSortArray(ByRef arr() As String)
Dim tmp1 As String, tmp2 As String
SortArray arr
For x = LBound(arr) To UBound(arr)
For y = x To UBound(arr)
If UCase(arr(x)) = "00" Then
tmp1 = arr(x)
tmp2 = arr(y)
arr(x) = tmp2
arr(y) = tmp1
End If
Next y
Next x
End Function

Sub SortArray(ByRef arr() As String)
Dim tmp1 As String, tmp2 As String
For x = LBound(arr) To UBound(arr)
For y = x To UBound(arr)
If UCase(arr(y)) < UCase(arr(x)) Then
tmp1 = arr(x)
tmp2 = arr(y)
arr(x) = tmp2
arr(y) = tmp1
End If
Next y
Next x
End Sub
``````
54565758_b.xlsm
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

ACCOUNTING ASSISTANTAuthor Commented:
Ryan Chong   Great Job !!

I like you solution

i would like to ask to you if posible to add an clean or delete button

because i will need change data very fast as needed

Im agreed to open an new question for it
0
Business Systems Analyst , ex-Senior Application EngineerCommented:
i would like to ask to you if posible to add an clean or delete button

in my existing codes, there's a part to clear the cells in column E.

see if that serve the purpose?

``````'Clear cells
ActiveSheet.Range("E" & StartRow & ":E" & LastRow).Cells.Clear
``````
0
ACCOUNTING ASSISTANTAuthor Commented:
Ryan Chong  thats  great

but i need change data in  column B  as needed

i mean need clean all over and change data

i will open an new question for it
0
ACCOUNTING ASSISTANTAuthor Commented:
Ryan Chong  Great Job !

Working as Needed Great  Expert !!
0
Business Systems Analyst , ex-Senior Application EngineerCommented:
for this question, you could use this for better handling:

Sub test()
Dim StartRow As Integer, LastRow As Integer, tmpArr() As String, idx As Integer
StartRow = 7
LastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "B").End(xlUp).Row

'Clear cells
ActiveSheet.Range("E" & StartRow & ":E" & LastRow).Cells.Clear

idx = 0

For i = StartRow To LastRow + 1
If ActiveSheet.Cells(i, "B") = "" Then
If idx > 0 Then
CustomeSortArray tmpArr
ActiveSheet.Cells(i - 1, "E") = "'" & Join(tmpArr, "")
idx = 0
ReDim tmpArr(idx)
End If
Else
ReDim Preserve tmpArr(idx)
tmpArr(idx) = ActiveSheet.Cells(i, "B")
idx = idx + 1
End If
Next i
End Sub
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.