Loop range and copy to different sheets in the same workbook

alfredgomez

New Member
Joined
Sep 21, 2022
Messages
6
Office Version
  1. 2021
Platform
  1. Windows
I have a multi-sheet workbook (.xlsm). The 1st sheet is a master sheet, editable, and contains all the data.
The other sheets (Classroom #) are subsets of the master based on which classroom the students are assigned to.

Basically, via individual formula's in the classroom sheets, I was able to copy the student information over to each individual classroom sheet based on the students assigned to the classroom.

The problem is that there are gaps on the classroom sheets where the other classroom students on the master were.

I need to use vba code to
- Select a range on the master sheet (B9:Q83)
- Loop through each row in the range
- Check the classroom value, Cell Q, of currently indexed row in the range.
- Based on the value of Cell Q above, copy range B through P of indexed row, to the appropriate classroom sheet starting from cell B9 of the classroom sheet so that there are no gaps.
- Classroom sheets are numbered (1,2,4,5,7,X).
- Classroom X denotes the student withdrew from the program so they should be skipped.

I tried to figure this out using the many sample vba programs on your site but have become overwhelmed by just trying to understand the code and how to modify it to suit my needs.

Thank you in advance for all of your help
Alfred Gomez
I.T. Coordinator
YMCA of Paterson
 

Attachments

  • Sheet1 (Master Sheet).jpg
    Sheet1 (Master Sheet).jpg
    243.3 KB · Views: 9
  • Sheet2 (Classroom 1).jpg
    Sheet2 (Classroom 1).jpg
    147.9 KB · Views: 7
  • Sheet6 (Classroom 7).jpg
    Sheet6 (Classroom 7).jpg
    190.2 KB · Views: 8

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,214,979
Messages
6,122,551
Members
449,088
Latest member
davidcom

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