Creating new worksheets and copying data automatically

culvekd

New Member
Joined
Apr 16, 2009
Messages
2
Hello-

I'm an English teacher, and VBA is new to me, but I know that Excel can do what I want. I keep a gradebook of all my students electronically, and Column A is their name, while Columns B-M are assignments they complete during the semester. So the primary worksheet is for my eyes only and has everyone's cumulative grades on it. What I'd like to do is be able to populate individual worksheets for each student (using a template perhaps?), naming the sheet with the student's name, and then having the individual assignment grades automatically entered onto that sheet in a different format than the primary.

For instance, the primary sheet would say John Doe|85|100|75

and a worksheet would be created titled John Doe that says
Assignment #1|85
Assignment #2|100
Assignment #3|75

so that I can print these out and give them to my students as a record of their grades.

I'm sure this is a multi-step process, and please keep in mind that I'm a noob, so you will have to tell me how to enter the code into VBA properly. I tried using a tutorial, and I'm generally pretty tech-savvy, but I keep getting a compile error following the tutorial's directions.

Thanks in advance for any advice or code!
 

Some videos you may like

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Makrini

Well-known Member
Joined
May 22, 2007
Messages
1,035
I wouldn't use a macro for this.

You can vlookup based on the name - and use data validation to have a dropdown of all the names in your master sheet. In that way - the template sheet populates with whatever name you have chosen - and that persons results.
 

culvekd

New Member
Joined
Apr 16, 2009
Messages
2
OK, thanks- I see how VLookup can work to copy the information from my master to each student's individual grades...but how can I have Excel automatically create a new worksheet based on the template (and inserting the correct data) based on the list of names?
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Welcome to the Board!

See if this does what you want:

<font face=Calibri><SPAN style="color:#00007F">Sub</SPAN> foo()<br>    <SPAN style="color:#00007F">Dim</SPAN> c <SPAN style="color:#00007F">As</SPAN> Range<br>    <SPAN style="color:#00007F">Dim</SPAN> i <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <SPAN style="color:#00007F">Dim</SPAN> MasterSheet <SPAN style="color:#00007F">As</SPAN> Worksheet<br>        <SPAN style="color:#00007F">Set</SPAN> MasterSheet = Sheets("Master")<br>    <br>        Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br>            <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> c <SPAN style="color:#00007F">In</SPAN> MasterSheet.Range([A2], Cells(Rows.Count, "A").End(xlUp))<br>                Worksheets.Add after:=Sheets(Sheets.Count)<br>                <SPAN style="color:#00007F">With</SPAN> ActiveSheet<br>                    .Name = c.Value<br>                    .Range("A1").Value = c.Value<br>                    .Range("B1").Value = "Grade"<br>                    <SPAN style="color:#00007F">For</SPAN> i = 2 <SPAN style="color:#00007F">To</SPAN> MasterSheet.Cells(c.Row, Columns.Count).End(xlToLeft)<br>                        .Cells(i, "A") = MasterSheet.Cells(1, i).Value<br>                        .Cells(i, "B") = MasterSheet.Cells(c.Row, i).Value<br>                    <SPAN style="color:#00007F">Next</SPAN> i<br>                <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>            <SPAN style="color:#00007F">Next</SPAN> c<br>            MasterSheet.Activate<br>        Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN><br>        <br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Hope that helps,
 

Watch MrExcel Video

Forum statistics

Threads
1,122,518
Messages
5,596,630
Members
414,082
Latest member
sasmita

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
Top