If cell value less than X, a new sheet is created based on a template

wong3

New Member
Joined
Jan 7, 2020
Messages
6
Office Version
  1. 2016
Platform
  1. Windows
Hi everyone,
I'm a teacher and I wanted to create notifications (new sheets based on a template) when a student scores less than 80%.

I have the following event code which will create a new sheet based on my template when a value is entered into a cell. I need two changes:
- Create a sheet when the value is less than 80 (instead of creating a sheet when a value is entered into the cell)
- Naming the sheet the student's name and the name of the test

If anyone can help. Thank you.

'Event code that runs if a cell value is changed
Private Sub Worksheet_Change(ByVal Target As Range)

'Check if the cell value in Column C is < 80
If Not Intersect(Target, Range("C:C")) Is Nothing Then

'Copy worksheet based on value in cell F2 in worksheet Sheet1 and put it last
Sheets(Worksheets("Sheet1").Range("F2").Value).Copy , Sheets(Sheets.Count)

'Rename worksheet to the value you entered.
ActiveSheet.Name = Target.Value

End If

'Go back to worksheet Sheet1
Worksheets("Sheet1").Activate

End Sub

NameEnglish TestMath Test
Red
50​
100​
Template:Template
Orange
100​
100​
Yellow
80​
90​
Green
90​
95​
Blue
88​
40​
Purple
92​
80​
Brown
20​
85​
Black
80​
92​
White
95​
50​
 

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"
May be:
PHP:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim WsName as string

'Check if the cell value in Column C is >= 80 or cell change not in column C then do nothing
If Intersect(Target, Range("C:C")) Is Nothing or target.value >=80 Then Exit Sub
WsName = Target,Offset(0,-2).value & "-" & cells(1,"C").value ' assume name of test is in row 1 ' for example: "Green - Math Test"

'Copy worksheet based on value in cell F2 in worksheet Sheet1 and put it last
Sheets(Range("F2").Value).Copy  After:=Sheets(Sheets.Count)

'Rename worksheet to the value you entered.
ActiveSheet.Name = WsName

'Go back to worksheet Sheet1
Worksheets("Sheet1").Activate
end sub
 
Upvote 0
Hello!

What information would be inside the new sheet?
The new sheet would have their name (sourced from the table), a list of the tests and the grades (also sourced from the table), and some boiler plate language of how the student scored a non-passing grade and how to remediate (this would be a free text box).
 
Upvote 0
The new sheet would have their name (sourced from the table), a list of the tests and the grades (also sourced from the table), and some boiler plate language of how the student scored a non-passing grade and how to remediate (this would be a free text box).
Basically, you want the copy of source sheet with student's name as tab name.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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