excel - Sorting column with more than one decimal -


i trying sort column values in excel sheet. ex:

1.2 2.1 3.1 1.1.1 1.2.3 

when click sort button should re-arrange.

1.2 1.1.1 1.2.3 2.1 3.1 

i have written sort code code sort single decimal values because integer when add more 1 dot excel converts has string. can please suggest wrong.

private sub sort_click()     dim xlsorta xlsortorder     dim lastrow long      activesheet         lastrow = .cells(.rows.count, "a").end(xlup).row          if (cint(.range("a2").value) > cint(.range("a" & cstr(lastrow))))             xlsorta = xlascending         end if          .range("a2:d10" & lastrow).sort key1:=.range("a2:d10"), order1:=xlsort, header:=xlno, _             ordercustom:=1, matchcase:=false, orientation:=xltoptobottom, _             dataoption1:=xlsortnormal      end       activeworkbook.save   end sub 

note: based on sort has re-arrange remaining columns working.

after split data of '1.2.3' "." , , sort data 3 columns in new sheet.

sub test()     dim vdb, rngdb range     dim ws worksheet, temp worksheet     dim vsplit, vr(), v     dim r long, c integer, long, n integer      set ws = activesheet     ws         lastrow = .cells(.rows.count, "a").end(xlup).row         set rngdb = .range("a2", "d" & lastrow)         vdb = rngdb         r = ubound(vdb, 1)         c = ubound(vdb, 2)     end     redim vr(1 r, 1 3)     set temp = sheets.add     temp         .range("a1").resize(r, c) = vdb         = 1 r             n = 0             vsplit = split(vdb(i, 1), ".")             each v in vsplit                 n = n + 1                 vr(i, n) = v             next v         next         .range("e1").resize(r, 3) = vr         .range("a1").currentregion.sort key1:=.range("e1"), order1:=xlascending, key2:=.range("f1"), order2:=xlascending, key3:=.range("g1"), order3:=xlascending         vdb = .range("a1").resize(r, c)         application.displayalerts = false         .delete         application.displayalerts = true     end     rngdb = vdb end sub 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -