Hi there,
I hope if someone may be able to help out on constructing a missing macro, essentially for moving/re-aligning some rows (but only the SPECIFIED ranges) not entire row, that can go awry (misaligned) when new entrants joined the class, or some have left, which may occur every time workbook is opened.
The workbook LBI is opened on each class day (Mon - Fri), at least once, normally 1 - 4 times per day. There are 3 different subjects and each subject is taught by a teacher. The actual sheet has 200 rows but is currently not filled to that yet. Each day, each of the teachers opens the same workbook LBI.xlsx after their class has been conducted, & inputs values in ranges A2:A,F2:H for each kid. The next teacher who resumes class for the next subject on same day does the same, & so on till the 3rd teacher ends for the day.
The 2 key tasks of the workbook each day are to: I) see macro segment 2a: assign AL:AN to BL:BN to register for previous class day scores, but based on the criteria that dates in each row AG2:AG not blank and not = TODAY() (in AG1), else do next step till loop ends. I have been able to make this macro with the kind help of @davesexcel. II) segment 2b: assign latest F:H scores to the corresponding rows in AL:AN every single time workbook is opened regardless if each AG date equals TODAY (AG1) or not.
The target ranges with issue are: AF2:AG,AL2:AN,BL2:BN. All other cells are bound by other simpler macros so must not be moved.
A new class for this fall isto be opened consisting of 9 students, the first day of school, on Oct 30, 2020.
On the 1st day Oct. 30 trial class, all students register their scores, and there is no previous day scores data, so BL2:BN is blank.
On the official day of class, Nov. 2, the sheet does its task and first assigns the Friday scores to BL2:BN, and then assigns the latest scores for each subject during the day into AL2:AN. (see img)
Attachment 701107
Attachment 701111
Same day, at the end of the 3rd subject, all scores are assigned. (see img)
Attachment 701112
And, similarly for the next class day.
Basically, this macro seems to be handling well, that is if students stay at 9 kids and if nobody leaves school, and no new entrants join. Now, if new entrants join the class, say 3 new kids Billy, Edgar & Kylie joined class on Nov. 4, total students now makes 12. Then, A2:A,F2:H expands below an additional 3 rows, but the ranges AF2:AG,AL2:AN,BL2:BN remain stuck at 9 rows, with rows most being out of synced with A2:A,F2:H. (see img)
3a.JPG
This makes a need to plug in additionally another segment 1 in my macro, before the above 2a,2b segments, so that every time as the workbook opens, it has to first check for any misaligned issue, by checking to see if there is at least 1 pre-existing filled value in AF2:AF becoming NOT equal to A2:A (to make sure not a single is out of sync), & if all are checked to be perfectly aligned then assign A2:A to Af2:AF, and proceed to do segments 2a,2b.
Else, do not assign to AF2:AF, instead go look for & select only those misaligned rows in the ranges (AF2:AG,AL2:AN,BL2:BN) & sync them (either move values?/move cells?) by matching AF2:AF with A2:A & bringing along with them the corresponding values in AF2:AG,AL2:AN,BL2:BN accordingly. (see img)
5.jpg
After much thought, I think this is the way to resolve this out-of-sync situation. Can anyone help? here'smy current macro:
Please Login or Register to view this content.
Stewart
Bookmarks