Adding a sort to my loop

Scarlacc

New Member
Joined
Apr 29, 2022
Messages
14
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
I have a sub that loops threw my list and separate the date in column E. When it hits date change it insert three rows and puts a date header at top of list. I'm trying to add into it a sort feature that will sort column A load numbers after it adds day header befor it moves down looking for next date change in E. Sure its something stupid im not catching. It will sort after the first day fine Up top but after that its pushing everything up into the blank rows. Dont have exact code with me. But it clears sort then sort.add with
key range("A1"),
orientation xlascending,

In sort I have range set to
selection, selection.end(xlup)
Header set to yes
Toptobottom
Forget other one off top of my head.

soon as it splits the days it will got to bottom cell in A and do xlup from previous day. Then come back down add header and continue down column E looking for next split.

I will attach an example of list kinda looks like without a header added. Ohh ya forgot to mention header is in merged Cell A to D. E gets deleted at end of the sub befor it moves on to next sub procedure.
 

Attachments

  • List Example.png
    List Example.png
    20.7 KB · Views: 7

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Don't worry about this must have been tired when trying this. All I needed to do was add second field to first sort thats done in beginning of this whole module. Dont know why that didn't come to me this morning.
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top