I am looking for vba code to sort columns based upon values in another set of columns. The number of columns will change row by row, thus it needs to be dynamic in nature.
For example, the first row may have the following fields in columns A-H:
Field_A, Field_B, Field_C, Field_D, 3, 2, 7, 1 (where the 4 numeric values correspond to the first 4 fields).
Thus, I would like to sort columns A-D based upon the values in E-H. I.E - the output columns should be:
Field_D, Field_B, Field_A, Field_C, 1, 2, 3, 7
I thought these could be loaded into a dynamic two dimensional array and then sorting, but not sure how to go about doing it. Open to other suggestions as well if there is a better way.
For example, the first row may have the following fields in columns A-H:
Field_A, Field_B, Field_C, Field_D, 3, 2, 7, 1 (where the 4 numeric values correspond to the first 4 fields).
Thus, I would like to sort columns A-D based upon the values in E-H. I.E - the output columns should be:
Field_D, Field_B, Field_A, Field_C, 1, 2, 3, 7
I thought these could be loaded into a dynamic two dimensional array and then sorting, but not sure how to go about doing it. Open to other suggestions as well if there is a better way.