Automatically Have a Cell Reference a Cell When a New Sheet is Created

CtrlAltRage

New Member
Joined
Aug 23, 2022
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Hey all,

I imagine there's an easy way to do this but I'm drawing a blank.

I have a sheet that will list projects I am working on.

On the first sheet (PROJECTS) when I enter in a project name (Column A), I've gotten it so that it automatically copies a sheet (Project Template) and creates a new sheet with the name of the sheet being the value of the project name I put in Column A.

What I'm trying to do is have it so that when the sheet is created, the first sheet (PROJECTS) automatically references specific cells in the newly created sheet in the row that the cell was updated. And when I add another project, creating a new sheet, I'd like that row to do the same, and so on.

To summarize:

- PROJECTS Sheet: I enter in "Project 1" under Column A/Project Name.

- The Project Template sheet gets copied and the name of the new sheet is now "Project 1"

- In the Project 1 sheet - A1 also has the name "Project 1"

---The above I have already gotten to work---


Then in the first sheet (PROJECTS), the row Project 1 was entered pulls the data from the newly created sheet under the "% Completed" and "Due Date" cells the respective cells under the PROJECTS sheet.

I hope that made sense - I've attached a file for reference. I am guessing as soon as I see the solution I'm going to facepalm at how easy it was.

Here is the first sheet (PROJECTS)

Project List Sheet.xlsm
ABCDEF
1PROJECT LIST
2PROJECT NAMEDATE ENTEREDDUE DATE% COMPLETEPRIORITYNOTES
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
PROJECTS



Here is the second sheet (Project Template)

Project List Sheet.xlsm
ABCDEFGH
1Project NameDue Date:1/1/2099
2
3
4TasksNotesPriorityCompletedStatusPriorityGrade
5üHigh5
6Medium3
7Low1
8
9
10Total Tasks0
11Completed Task Score0
12Total Task Score0
13% Completed0%
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Project Template
Cell Formulas
RangeFormula
G10G10=COUNTIF($A$5:$A$29,"<>")
G11G11=COUNTIFS($C$5:$C$29,$G$5,$D$5:$D$29,$F$5)*$H$5+COUNTIFS($C$5:$C$29,$G$6,$D$5:$D$29,$F$5)*$H$6+COUNTIFS($C$5:$C$29,$G$7,$D$5:$D$29,$F$5)*$H$7
G12G12=COUNTIF($C$5:$C$29,$G$5)*$H$5+COUNTIF($C$5:$C$29,$G$6)*$H$6+COUNTIF($C$5:$C$29,$G$7)*$H$7
G13G13=IFERROR(G11/G12,0)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A5:D29Expression=AND($D5=$F$5,$A5<>"")textNO
Cells with Data Validation
CellAllowCriteria
C5:C29List=$G$5:$G$8



Thanks in advance!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Not sure 100%, but this code trigger any change/ update in column A of sheet PROJECTS, dupplicate sheet template, then create formula in sheet PROJECTS to get value from new sheet.
Right click on sheet name, View Code then paste below code into:
VBA Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Columns(1)) Is Nothing Or Target.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Evaluate("=ISREF(" & Target.Value & "!A1)") Then
    Sheets("Project Template").Copy after:=Sheets(Sheets.Count)
    ActiveSheet.Name = Target.Value
End If
Me.Activate
Target.Offset(, 2).Formula = "=" & Target.Value & "!D1"
Target.Offset(, 3).Formula = "=" & Target.Value & "!G13"
End Sub
 
Upvote 0
Not sure 100%, but this code trigger any change/ update in column A of sheet PROJECTS, dupplicate sheet template, then create formula in sheet PROJECTS to get value from new sheet.
Right click on sheet name, View Code then paste below code into:
VBA Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Columns(1)) Is Nothing Or Target.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Evaluate("=ISREF(" & Target.Value & "!A1)") Then
    Sheets("Project Template").Copy after:=Sheets(Sheets.Count)
    ActiveSheet.Name = Target.Value
End If
Me.Activate
Target.Offset(, 2).Formula = "=" & Target.Value & "!D1"
Target.Offset(, 3).Formula = "=" & Target.Value & "!G13"
End Sub
That worked wonderfully, thank you!

Now, if you don't mind me asking - if I wanted to take the names of the projects that the sheets were named after and turn them into links to their respective sheets, where would I place that code?
 
Upvote 0
Add one more selection change event to trigger column A select (instead of add hyperlink into cell)
VBA Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Columns(1)) Is Nothing Or Target.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Evaluate("=ISREF(" & Target.Value & "!A1)") Then
    Sheets("Project Template").Copy after:=Sheets(Sheets.Count)
    ActiveSheet.Name = Target.Value
End If
Me.Activate
Target.Offset(, 2).Formula = "=" & Target.Value & "!D1"
Target.Offset(, 3).Formula = "=" & Target.Value & "!G13"
End Sub

'ADDED
'--------------------------------------------------------------------
Private Sub Worksheet_selectionChange(ByVal Target As Range)
If Intersect(Target, Columns(1)) Is Nothing Or Target.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Evaluate("=ISREF(" & Target.Value & "!A1)") Then Exit Sub
Sheets(Target.Value).Activate
End Sub
 
Upvote 0
Add one more selection change event to trigger column A select (instead of add hyperlink into cell)
VBA Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Columns(1)) Is Nothing Or Target.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Evaluate("=ISREF(" & Target.Value & "!A1)") Then
    Sheets("Project Template").Copy after:=Sheets(Sheets.Count)
    ActiveSheet.Name = Target.Value
End If
Me.Activate
Target.Offset(, 2).Formula = "=" & Target.Value & "!D1"
Target.Offset(, 3).Formula = "=" & Target.Value & "!G13"
End Sub

'ADDED
'--------------------------------------------------------------------
Private Sub Worksheet_selectionChange(ByVal Target As Range)
If Intersect(Target, Columns(1)) Is Nothing Or Target.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Evaluate("=ISREF(" & Target.Value & "!A1)") Then Exit Sub
Sheets(Target.Value).Activate
End Sub
Thanks again! For some reason when I apply that last bit of code when I enter in a new task in the PROJECTS tab it asks me to open a file.
 
Upvote 0
Try to attach a screenshot with the pop up message asking to open a file.
 
Upvote 0

Attachments

  • Screenshot_4.png
    Screenshot_4.png
    106.1 KB · Views: 6
Upvote 0
UPDATE:

It seems to only happen when I have spaces in the project name I enter in.
 
Upvote 0
UPDATE:

It seems to only happen when I have spaces in the project name I enter in.
The spreadsheet works great and I appreciate the help! Is there anyway I can fix it so that the Update Values Prompt doesn't show up when I enter in a task with spaces in it?
 
Upvote 0

Forum statistics

Threads
1,215,161
Messages
6,123,377
Members
449,097
Latest member
Jabe

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