Extract and arrange the numbers small to larger values

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,360
Office Version
  1. 2010
Hello,</SPAN></SPAN>

I need to extract the numbers of column E:N and need to arrange them in order small to larger values in the columns P:Y
</SPAN></SPAN>

Example


Book1
EFGHIJKLMNOPQRSTUVWXY
1
2
3n1n2n3n4n5n6n7n8n9n10n1n2n3n4n5n6n7n8n9n10
40000000110131113
500090010012139101213
600000910012091011
70000001000131013
800000901112091112
900000901101391113
100340091000034910
111234500090123459
Sheet1


Thank you all
</SPAN></SPAN>

Excel 2000
</SPAN></SPAN>
Regards,
</SPAN></SPAN>
Moti
</SPAN></SPAN>
 
Last edited:
Try this, This should write from P to Y without altering other columns.

Code:
Sub arrange_numbers1()
  Dim c As Range, j As Long
  For Each c In Range("E4:N" & Range("E" & Rows.Count).End(xlUp).Row)
    If c.Column = 5 Then j = Columns("P").Column
    If c <> 0 Then
      Cells(c.Row, j) = c
      j = j + 1
    End If
  Next
End Sub
DanteAmor, yes this is spot on running perfect, thank you for your help</SPAN></SPAN>

Kind Regards, </SPAN></SPAN>
Moti :) </SPAN></SPAN>
 
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Another option
Code:
Sub Motilulla()
    Dim Ary As Variant, Nary As Variant
    Dim r As Long, c As Long, nc As Long
    
    Ary = Range("E4", Range("N" & Rows.Count).End(xlUp)).Value2
    ReDim Nary(1 To UBound(Ary), 1 To UBound(Ary, 2))
    For r = 1 To UBound(Ary)
        For c = 1 To UBound(Ary, 2)
            If Ary(r, c) > 0 Then
                nc = nc + 1
                Nary(r, nc) = Ary(r, c)
            End If
        Next c
        nc = 0
    Next r
    Range("P4").Resize(UBound(Nary), 10).Value = Nary
End Sub
 
Upvote 0
Solution
HI
What about
Code:
Sub test()
    Dim b As Variant
    Dim lr, i
       For i = 5 To Cells(Rows.Count, 5).End(xlUp).Row
        ReDim b(1 To 10)
        t = 1
        For j = 5 To 15
            If Cells(i, j) <> 0 Then
                b(t) = Cells(i, j): t = t + 1
            End If
        Next
        Cells(i, 16).Resize(, UBound(b)) = b
    Next
End Sub
mohadin, yes your code also worked fine,just changed 5 to 4, thank you for your help
Code:
For i = [COLOR=#ff0000]4[/COLOR] To Cells(Rows.Count, 5).End(xlUp).Row

Kind Regards,
Moti
:)
 
Upvote 0
Another option
Code:
Sub Motilulla()
    Dim Ary As Variant, Nary As Variant
    Dim r As Long, c As Long, nc As Long
    
    Ary = Range("E4", Range("N" & Rows.Count).End(xlUp)).Value2
    ReDim Nary(1 To UBound(Ary), 1 To UBound(Ary, 2))
    For r = 1 To UBound(Ary)
        For c = 1 To UBound(Ary, 2)
            If Ary(r, c) > 0 Then
                nc = nc + 1
                Nary(r, nc) = Ary(r, c)
            End If
        Next c
        nc = 0
    Next r
    Range("P4").Resize(UBound(Nary), 10).Value = Nary
End Sub
Fluff, Thank you for the help, yes your code also gave a required result Ok.

Kind Regards,
Moti
:)
 
Upvote 0
My pleasure & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,553
Messages
6,120,179
Members
448,948
Latest member
spamiki

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