VBA Macro - Sort row (left to right) based on a pre-sorted worksheets

  • sorry one more. possible to retain the font, font colour, highlight colour? rather than shift only the letter/number, can it shift it as a whole (with font, font colour, highlight colour)?


    With the file I attached or with the code copy/pasted to your actual file?

  • Try changing the "CustomSort" code to


    Leave the ArraySort code as it is.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • If you set the required format (font colour etc.) for the whole data area, then the macro will not change that and formatting should be correct after macro run.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • ehh.


    no. At the data sheet, some number had unique font colour & highlighted to represent something, tht y i cant set it as a whole.
    That y the previous script will not change anything and only shift the position.


    If you set the required format (font colour etc.) for the whole data area, then the macro will not change that and formatting should be correct after macro run.

  • This work but it cant retain the original colour / highlight.
    Some data is highlighted for special remark. I hope it can retain the riginal colour / highlight. only shift the position.


    Try changing the "CustomSort" code to


    Leave the ArraySort code as it is.

  • What determines the formatting of each value?

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Hi,


    On the data, some number had unique font colour or highlighted font colour + font colour. Depend.


    Keep the original (font colour or highlighted font colour + font colour) but only shift the position.



    What determines the formatting of each value?

  • I sent you a PM

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • You're welcome. Pleased we got there in the end.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Can you attach the actual file with the 5000+ rows of data.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!