PDA

View Full Version : Problem about sort horizontal with Function.



thanhvanchi
12-05-2016, 08:02 PM
Hello everyone!
I need your help and expertise here. I'm trying to get my head around VBA to sort horizontal rows based on comparison of certain values under specific column headings.
Before the results are as shown in the URL image below.


ColumnA ColumnB ColumnC ColumnD ColumnE ColumnF ColumnG ColumnH
111 222 333 444 555 666 777 888


ColumnB and ColumnF have similar header name like "cost_default_smsc_1" and "cost_default_smsc_2". The cost will be compared and then display in ascending order.
Taking for example, ColumnF of 666 is cheaper than ColumnB of 222.
Column A, B,C,D belonged to a set of product, while E,F,G,H belong to another set. There are up to 10 products.


The resulting output in this case will be,


ColumnA ColumnB ColumnC ColumnD ColumnE ColumnF ColumnG ColumnH
555 666 777 888 111 222 333 444

Thank's a lot!

mikerickson
12-05-2016, 09:33 PM
It sounds like you want to look at the four cell block A1:D1 , compare it with the four cell block E1:H1

And the swap (or not) those blocks of 4 cells depending on the value of the second cell.

Is that the goal?

Where do you want the resulting values?

Could you attach a workbook with some sample data and the desired result?