Share via

VBA Sort functions not recognizing header

Anonymous
2024-07-09T18:23:17+00:00

Hello,

I have the following file layout:

Here is the VBA Code associated with the 4 ActiveX buttons shown above:

Unfortunately, the sort buttons are also sorting the column headers in Row 9. What do I need to tweak in the last set of codes to ensure that he Column Heading remain in Row 9? Hope you can help.

Regards,

Sam.

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2024-07-09T19:59:40+00:00

Sorry, a typo. coll should have been col

Range(Range("A9"), Range("A9").End(xlDown).End(xlToRight)).Sort Key1:=Cells(9, col), Order1:=ord, Header:=xlYes

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2024-07-09T19:49:31+00:00

    Hi Hans,

    Thanks for the tweak. Unfortunately, I am getting a compile error:

    Was this answer helpful?

    0 comments No comments
  2. HansV 462.6K Reputation points
    2024-07-09T19:12:19+00:00

    Range(Range("A9"), Range("A9").End(xlDown).End(xlToRight)).Sort Key1:=Cells(9, coll), Order1:=ord, Header:=xlYes

    Was this answer helpful?

    0 comments No comments