Requirements: All classes of the school semester, each teacher may have a few courses, but to a teacher to adjust the class time to find out if there are any other classes in the instructor conflict, manual search is inconvenient, here to show the same teacher in the table in all classes in the time position, Implemented as follows, this program is still a good solution to this problem.
SubTest ()SetCURWS = ActiveSheet'Defining activity TablesCurws. Cells.clearformats'Clear formatting from a tableuser = Range ("af2")'take the name of the class IfIsEmpty (user) Then MsgBox "af2 add A person's name to a cell" Exit Sub End If 'Loop All Tables for eachWsinchWorksheetsSetLASTRG = ws. Range ("a65536"). End (Xlup)'Select the range of cells for the instructor's and class abbreviationsLastRow = Lastrg.row'take the last lineStartRow = Lastrg.end (xlup). Row'Start line fori = StartRow toLastRow-1 IfWs. Range ("N"& i) = user Then 'Find the instructor and take the corresponding class abbreviationv = ws. Range ("g"&i). Value'cycle through the course range of a curriculum for eachRginchWs. Range ("C7:ad"& StartRow-2) IfRg. Value = V Then 'adds an undertone to the corresponding cell in the current active table from the corresponding absolute positionCurws. Range (RG. Address). Interior.ColorIndex =3 End If Next End If Next NextEnd Sub
VBA realizes all the classes in the school, and in one page, the background color reflects.