VBA realizes all the classes in the school, and in one page, the background color reflects.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.