vba - How to sort an excel sheet according to sort order of my original excel sheet? -


using chrome extension 'webscraper.io', regularly scraping government website track updated project expenses. although efficient in operation, it's failing return data in same order providing input url's. , more weirdly every time run task picking different order though source same. suppose, if run task of 5 url's twice, output (no specific random order):

(day 1) output  (day 2) output url 2   $500    url 3   $478  url 4   $867    url 1   $637  url 1   $928    url 4   $102  url 3   $109    url 5   $942  url 5   $208    url 2   $296  

image example

it makes side side comparison of different days of data extremely tedious task me. so, there way sort columns of sheet 2 according sort order of sheet 1? alphabetical sorting of both sheets 1 option, breaks original order (which department wise). ideally want paste column b of days original sheet & compare changes.

you may want use sort method of range object ordercustom parameter

sub sortbyurls()     dim rngtosort range, keystosort range      worksheets("urls") '<--| change "urls" actual sheet name         set rngtosort = .range("c2:d6") '<--| range sorted         set keystosort = .range("c2") '<--| first cell of column sort          application.addcustomlist listarray:=.range("a2:a6").value '<--| add sorting custom list previous url names range          .sort.sortfields.clear '<--| clear preceeding sorting settings         rngtosort.sort key1:=keystosort, order1:=xlascending, header:=xlguess, _             ordercustom:=application.customlistcount + 1, matchcase:=false, _             orientation:=xltoptobottom, dataoption1:=xlsortnormal          application.deletecustomlist application.customlistcount '<--| delete sorting custom list     end end sub 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -