Sorting Groups of Rows Excel VBA Macro

前端 未结 1 1865
别跟我提以往
别跟我提以往 2020-12-10 08:56

I am having trouble figuring out how to create a sorting algorithm in VBA that sorts and swaps groups of rows (several rows at a time). I wrote a successful sorting algorit

相关标签:
1条回答
  • 2020-12-10 09:19

    I agree that the question is still a little unclear. Have you tried doing a sort from the Data>Sort... You can sort using multiple keys and use custom lists.

    Additionally since you said you wanted some pointers on the VBA...:) I don't think stuff like

    Dim letString, idLabel, curCell As String
    

    is doing what you are expecting. What is actually happening here is

    Dim letString as Variant, idLabel as Variant, curCell As String
    

    because you don't specify after each variable. I assume what you want here is actually:

    Dim letString as String, idLabel as String, curCell As String
    

    Second, if you are concerned about efficiency like in your last comment then I would avoid using the .select method of manipulating ranges. You can do everything in excel without it. It is just an extra burden. So instead of doing something like Selction.Resize(1).Select you could log the locations of the beginning and end of your rand in an integer variable then change it into a range object once all your criteria are met. You can feed this range object into your sorting function.

    Just something to chew on.

    0 讨论(0)
提交回复
热议问题